[daily] Go language Bible - variable parameter exercises

1. Functions with variable number of parameters are called variable parameter functions, such as fmt.Printf and similar functions2. Add the ellipsis "..." before the last parameter type in the parameter list3. Although in the variable parameter function, the behavior of int type parameter looks like slice type, in fact, the variable p ...

Posted by jalbey on Sun, 05 Apr 2020 12:22:04 -0700

[daily] Go language Bible -- compound data type, array exercise

go language Bible - composite data type 1. Composite data types that can be constructed by combining basic types in different ways 2. Four types -- array, slice, map and structure 3. Array is composed of isomorphic elements - each array element is of the same type - structure is composed of heterogeneous elements 4.slice and map are dynamic dat ...

Posted by jesirose on Fri, 03 Apr 2020 11:41:51 -0700

dotsql of Go Language Library Series

Guide: is it very interesting to be able to carry out a single line or lines of SQL files? Today, let's introduce this interesting Library -- dotsql. Background introduction dotsql is not an ORM or a builder of SQL query statements, but a tool that can carry out several lines in an SQL file, very similar to the reading of ini configuration fi ...

Posted by ~n[EO]n~ on Thu, 02 Apr 2020 19:14:54 -0700

[daily] Go language Bible -- JSON exercise 2

Exercise 4.12: the popular web comic service xkcd also provides a JSON interface. For example, an https://xkcd.com/571/info.0.json request will return a detailed description of the 571 number that many people love. Download each link (only once) and create an offline index. Write an xkcd tool that uses these offline indexes to print the URL ...

Posted by vigour on Wed, 01 Apr 2020 07:44:17 -0700

Implementing Http server in Golang and parsing header parameters and form parameters

In HTTP service, header parameters and form parameters are often used. This article is mainly to practice how to parse the parameters and form parameters in the header of HTTP request in Go language. The specific code is as follows: package server import ( "net/http" "strconv" "fmt" ) func HttpStart(port int) { http.HandleFunc(" ...

Posted by KCAstroTech on Wed, 01 Apr 2020 05:54:39 -0700

[daily] Go language Bible -- example: concurrent Clock service exercises

Exercise 8.1: modify clock2 to support the incoming parameter as the port number, and then write a clockwall program. This program can communicate with multiple clock servers at the same time, read the time from multiple servers, and display the results of all services in one table, similar to the clock wall you see in some offices. If you have ...

Posted by jb60606 on Mon, 30 Mar 2020 11:47:23 -0700

Methods in Go language

1.1 method statement The declaration of the method is similar to that of a normal function, except that a parameter is added before the function name. This parameter binds this method to the type corresponding to this parameter import ( "fmt" ) type Point struct { x, y int } func fun() { ...

Posted by ngoweb on Sat, 28 Mar 2020 09:22:16 -0700

Go language introduction structure & Practice

Structure & Practice structural morphology Definition The object-oriented in Go is realized by struct, which is a user-defined type //Define structure /Define structure type User struct { Name string Gender string Age int AvatarUrl string } func useStruct() { //Initialize structure 1 var user1 User u ...

Posted by godwisam on Thu, 26 Mar 2020 09:09:21 -0700

Go golang Quick Start [8.3] - Deep understanding of IEEE754 floating point numbers

Previous Introduction to Goang Quick Start [1]-go Language golang Quick Start [2.1]-go Language Development Environment Configuration-windows golang Quick Start [2.2]-go Language Development Environment Configuration-macOS golang Quick Start [2.3]-go Language Development Environment Configuration-linux golang Quick Start [3]-go helloworld How ...

Posted by gvp16 on Tue, 24 Mar 2020 11:12:45 -0700

Source Interpretation of Golang's sync.Map Implementation Principle

brief introduction Gos built-in maps do not support concurrent write operations, because map write operations are not concurrently secure. When you try multiple Goroutine operations on the same map, an error occurs: fatal error: concurrent map writes. So sync.Map has been officially introduced to accommodate concurrent programming applications. ...

Posted by skeener on Sun, 22 Mar 2020 22:56:00 -0700