Go Language Self-Study 18: Process Control Paper

There are so many process control methods in Go: if - else conditional statement switch - case selection statement for - range loop statement goto unconditional jump statement Defer defer execution if-else conditional statement if condition 1 { Branch 1 } else if conditio ...

Posted by nologin666 on Fri, 14 Feb 2020 23:13:08 -0800

Go language defer and recover

1.defer is the code segment executed when the function returns. Whether it is return or panic, the code snippet in defer will be executed. 2.recover is used to capture panic in the defer code segment. When panic occurs, the defer code segment will be executed, in which if recover is available, The panic will be captured and use ...

Posted by Dongowarrior on Thu, 13 Feb 2020 12:45:04 -0800

Interface of Go language foundation

The interface defines the behavior specification of an object. The interface only defines that the specification is not implemented, and the specific object implements the details of the specification. 1.1 interface type In Go language, interface is a type, an abstract type. interface is a set of method s, which is an embodiment of duck type p ...

Posted by kjharve on Thu, 06 Feb 2020 01:31:18 -0800

Only 180 lines of code are needed to develop blockchain with Go language

What language does blockchain development use? Through this article, you will use go language to develop your own blockchain (or build blockchain with go language), understand how hash function keeps the integrity of blockchain, master how to create and add new blocks with go language programming, realize multiple nodes to generate blocks th ...

Posted by chalexan on Mon, 03 Feb 2020 05:13:46 -0800

Gorang learning series - 20. Package

Catalog   1, Standard library 1. regexp package: regular expression 2. sync package: lock and sync 2.1 sync.Mutex mutex 2.2 sync.RWMutex read / write lock 2.3 once.Do(call) 2, Use of packages 1. Custom package 2. reference package 3. Initialization of package 1, Standard library Built i ...

Posted by unbreakable9 on Fri, 17 Jan 2020 04:15:47 -0800

[Environment] go mod--a love-hate package management tool

Why do we need package management Python has pip, Nodejs has npm.Is there a package management tool in other languages, so go needs it?Of course not, let's look at the following code: import ( "github.com/TomatoMr/something" ) This is how go references packages, which is obviously a third-party package, so how exactly is it found on our m ...

Posted by bdbush on Tue, 14 Jan 2020 09:18:17 -0800

Program control of go

The program control of go is roughly divided into three if for case statements 1. if loop There can be any number of else if between if else statements.The order of condition judgment is from top to bottom. If the if or else if condition determines that the result is true, the corresponding code block is executed. If no condition is true, the ...

Posted by Blockis on Sat, 11 Jan 2020 06:27:18 -0800

JWT realizes authorization authentication

Catalog 1, What is JWT 2, JWT Standard Specification 3, Analysis of core code 4, Login authorization example 5, JWT usage 6, JWT considerations 1, What is JWT JSON Web Token (JWT) is the most popular cross domain authentication solution. In short, OAuth is a kind of authoriz ...

Posted by w4designs on Wed, 08 Jan 2020 08:10:31 -0800

fmt.Printf of Golang Foundation

background When printing in go language, we often see different printing methods, such as println, fmt.Println and fmt.Printf Differences and usage Source code of fmt.Println // Println formats using the default formats for its operands and writes to standard output. // Spaces are always added between operands and a newline is appended. ...

Posted by Byron on Wed, 08 Jan 2020 07:18:43 -0800

Notes on golang slice

1 slice initialization 1 func printSlice(s []int) { 2 fmt.Printf("len=%d cap=%d underlying array:%p, %v\n", len(s), cap(s), s, s) 3 } 4 5 func sliceInit() { 6 7 var s1 []int //Declare s1, and it is not initialized. At this time, s1 is nil slice, and the underlying array is not allocated 8 if s1 == nil { 9 fmt.P ...

Posted by Imad on Tue, 07 Jan 2020 02:09:49 -0800