Mutex Learning Notes

Mutex Critical zone In concurrent programming, if a part of the program is accessed or modified concurrently, to avoid unexpected results caused by concurrent access, this part of the program needs to be protected. The protected part of the program is called the critical zone. A critical zone can be a shared resource or an entire set o ...

Posted by ym_chaitu on Sun, 19 Sep 2021 02:19:40 -0700

Source code analysis - Golang Map

Correlation constant parsing bucketCntBits = 3 // It represents bit bucketCnt = 1 << bucketCntBits // Represents a bucket(bmap) with a maximum storage of 8 key s loadFactorNum = 13 loadFactorDen = 2 // The load factor is calculated from these two factors (the load factor is related to when to trigger capacity expansion) maxKeySize ...

Posted by sufian on Sat, 18 Sep 2021 22:23:59 -0700

json parsing of Go: Marshal and Unmarshal

brief introduction json (JavaScript object notation) is a data exchange format, which is commonly used for front and rear data transmission. Either end converts the data into a json string, and the other end parses the string into a corresponding data structure, such as string type, strcut object, etc. go language itself provides us with json ...

Posted by ch3m1st on Fri, 17 Sep 2021 18:52:54 -0700

DDD actual combat sharing - Message Center

What problem does DDD solve / why use DDD You can write your answers in the comments area DDD overall process (source: ThoughtWorks) v1 v2 The biggest difference is that the event storm in the first step is replaced by the identification core domain of strategic design. Personally, I don't think it's suitable to discuss ...

Posted by codecontractor on Fri, 17 Sep 2021 01:04:26 -0700

Go ----- common functions (strings, time)

Go common functions Official website: https://golang.org/pkg/ golang official website 1, strings handles string related Statistics string length, in bytes len(str) String traversal,Processing Chinese r:=[]rune(str) String to integer n, err := strconv.Atoi("12") Integer to ...

Posted by e39m5 on Tue, 14 Sep 2021 17:15:19 -0700

Golang benchmark - Test code performance

preface Performance is a very important indicator when optimizing code or determining algorithm selection. For example, I need to use hash algorithm for signature when making requirements recently. At first, I wanted to use md5 without thinking about it, and then a few big words popped up on the IDE: md5 has known security problems, so it is r ...

Posted by benphelps on Tue, 14 Sep 2021 12:03:01 -0700

Go language learning notes-006 slice

Slice of Go language foundation Because the length of the array is fixed and the length of the array is part of the type, the array has many limitations, such as summing the parts of the array. package main import "fmt" func arraySum(x [3]int) int { var sum int for _, v := range x { sum += v } return sum } func main ...

Posted by jack_indigo on Mon, 13 Sep 2021 12:49:15 -0700

3, User management microservice (Library User Service)

Microservice library user service, user management service. It provides a Restful interface for user management, which mainly realizes the functions of user registration, querying users according to user ID or email, querying books borrowed by users, etc. Full code: https://github.com/Justin02180218/micro-kit Package structure descriptio ...

Posted by chele on Sat, 11 Sep 2021 23:19:42 -0700

go defer,panic,recover explain go exception handling in detail

Reprint   https://www.jianshu.com/p/63e3d57f285f In golang, defer, panic and recover are three common features. When used together, they can act as try... catch... In other languages, and defer itself is like a destructor in other languages defer A function will be followed by defer, but the function will not be executed immediately. In ...

Posted by cookiemonster4470 on Tue, 07 Sep 2021 14:51:10 -0700

2021-09-04 the simplest Golang timer application and the simplest introduction to collaboration

package main import ( "fmt" "time" ) type Timer struct { Interval int // set time interval Tick func() // When the time is up, which program will be called? } func (t Timer) Enabled() chan bool { channel := make(chan bool) // Create a channel ticker := time.NewTicker(time.Duration(t.Interval) * time.Millisecond) // A ti ...

Posted by gordonrp on Fri, 03 Sep 2021 19:07:01 -0700