[Golang program flow control]
1, Introduction to program flow control
Sequential controlBranch controlCycle control
2, Sequential control
1) Connotation 2) Flow chart 3) Note = = the definition variable adopts legal forward reference
3, Branch control
1. Basic introduction of branch control
Single branchDouble branchMulti branch
2. Single branch control ...
Posted by CarbonCopy on Sun, 06 Feb 2022 08:46:05 +0100
New features of experimental Go generics
New features of experimental Go generics:
I Prerequisite: run the following two lines of commands to download the go compilation environment that supports running generics.
go get golang.org/dl/go1.18beta1@latest
// Download go1 18beta1 executable file to the bin directory of go configuration
go1.18beta1 download
// Check whether the download ...
Posted by dillonit on Sun, 06 Feb 2022 03:54:04 +0100
[GO Language 04-1] GoLanguage on function definition, closure function, scope, defer keywords in detail
Functional encapsulation in the Go language is done through functions, and different structures can be unified through interfaces. Combined with reflection characteristics, large and complex projects can be developed.
1. Definition of functions
The Go language supports object-oriented programming, but functions are the basic elements of th ...
Posted by Shai-Hulud on Fri, 04 Feb 2022 18:41:01 +0100
go array and slice [golang notes]
1, Array
An array is a collection of data of the same type. Each data contained in the array is called an array element. This type can be the original type of meaning, such as int, string, etc., or a user-defined type. The number of elements contained in an array is called the length of the array. In Golang, array is a data type with a fixed l ...
Posted by rubric on Fri, 04 Feb 2022 09:59:27 +0100
slice of Go language
What is slice
The length of the go array cannot be changed, so such a set is not applicable in a specific scene. Go provides a flexible and powerful built-in type slice ("dynamic array"). Compared with the array, the length of the slice is not fixed, and elements can be added, which may increase the capacity of the slice
The slice t ...
Posted by systemick on Fri, 04 Feb 2022 08:29:39 +0100
GoFrame framework (RK boot): differentiated configuration file (Config) based on cloud native environment
introduceThrough a complete example, in gogf/gf In the framework, the configuration files are distinguished according to the environment. That is, how to read different configuration files in [test], [Online] and other environments.We will use rk-boot To start gogf/gf Microservices.Please visit the following address for a complete tutorial:http ...
Posted by westair on Thu, 03 Feb 2022 13:08:00 +0100
go language foundation ------ 15 ------ reflection
1 reflect
1) Definition of reflection: in computer science, reflection refers to the access, detection and repair of computer programs at Run time An ability to change its own state or behavior. Figuratively speaking, reflection is that the program can "observe" and repair when running Change your behavior. 2) The meaning of go ref ...
Posted by nipsilanti on Thu, 03 Feb 2022 09:24:53 +0100
Summary of basic knowledge points of Golang language
Summary of basic knowledge of Golang language
1.go language has two types:
Value type: numeric type, bool, string, array, struct structure Variables store values directly. Memory is usually allocated in the stack. Modifying the value will not affect the source objectReference types: pointer, slice, pipe, chan, map, interface The variable stor ...
Posted by Harbinger on Thu, 03 Feb 2022 03:59:16 +0100
Golang:JSON, int64 and interface
Let's take a look first: About JSON number
Cross reference relationship between golang data type and json type:
bool, for JSON booleans
float64, for JSON numbers
string, for JSON strings
[]interface{}, for JSON arrays
map[string]interface{}, for JSON objects
nil for JSON null
There is no int64 type in json. When deserializing, if you dire ...
Posted by Toby on Tue, 01 Feb 2022 23:43:28 +0100
Sharing of GO channel and sync package
[TOC]
Sharing of GO channel and sync package
Let's review what we shared last time:
If there are no restrictions on GO synchronization, data race will occurWe use locks to solve the above problems. We choose to use mutex locks and read-write locks according to the usage scenarioA better way than using locks is atomic operations, but using go ...
Posted by artyfarty on Tue, 01 Feb 2022 18:34:52 +0100