• Explain in detail the error handling in the concurrent environment of go multiprogramming


    introduction In go language, we usually use panic and recover to throw and catch errors. This pair of operations can be used normally in a single coroutine environment, and we won’t step into any pits. However, we often encounter the following two problems in the concurrency environment. Let’s say we have two coroutines. Let’s call […]

  • Go structure format output


    When locating problems in software system, log is indispensable, but when a system has many functions and needs to print a lot of logs, at this time, in order to improve the efficiency of browsing log, easy to read output format is essential. Printing structure is the longest operation when printing log, but it is […]

  • Go concurrency


    Golang naturally supports concurrency at the language level. It’s a very good language. Sometimes when we encounter complex scenarios in business development, we need to use it for concurrency. We use the coprocessor group to complete the concurrency of multiple requests. When we encounter nested loops, there are context relationships that need to be transformed […]

  • Analysis of go string fingerprint


    When writing a project, sometimes we need a cache, and the cache will need a unique key. The general method is to find the MD5 fingerprint of a string. We can also use it in golang. At present, we can calculate the fingerprints of CRC32, MD5, SHA1 of a string MD5: a widely used cryptographic […]

  • An example of IP segment range verification in go language


    background Recently, we have made a requirement to detect whether an IP is in a number of IP segments, and do IP screening at fixed locations to meet specific business requirements. Solution Plan a dot decimal range discrimination In short, it is to compare the IP addresses of the original four segments of IPv4 to […]

  • Go strconv package


    Strconv package This package mainly realizes the conversion between the basic data type and its string representation. The common functions areAtoi()、Itia()、parseSeriesformatSeriesappendSeries. For more functions, seeOfficial documents。 String and int type conversion Atoi() This function is used to convert integers of string type tointThe function signature is as follows: func Atoi(s string) (i int, err error) […]

  • The ORM framework of operating database for golang common libraries


    Common library of golang: used by gorilla / mux HTTP routing Library Common libraries in golang: profile parsing library Viper Common libraries of golang: ORM framework for operating database – basic use of Gorm 1: Field mapping model definition In Gorm, struct is usually used to map fieldsGorm tutorialZhongjiaoModel definition For example, we define a […]

  • How to use GoLand ide go mod to build a project


    No matter what programming language you learn, there are four steps you will go through at the beginning Development tools installation IDE installation Set dependency / package image Project building tools, managing dependencies / packages 1、 Installation of golang development tools https://golang.org/ Official website (need respective means)https://github.com/golang/go GitHub addresshttp://docscn.studygolang.com/ Golang Chinese website 2、 GoLand ide […]

  • Detailed introduction and use of go module


    Go1.1.1It’s been a few days since the release of the version (August 24, 2018). We can see from the official blog that there are two prominent features. One is what I’m talking about todaymoduleModule concept. At present, the function is still in the experimental stage, and some places need to be improved continuously. Before the […]

  • Implementation of two go programs printing a slice in turn


    Problem Description: The two processes print a slice in turn. Golang implementation: Two channels are used for judgment only package main import ( “fmt” “sync” ) //Two processes print a slice in turn func main() { ch1 := make(chan bool, 1) ch2 := make(chan bool, 1) ch1 <- true nums := []int{1, 2, 3, 4, […]

  • Go language to guess the number of small games


    Using go language to achieve a four digit, and do not repeat the number guessing game, the solution is to first use the RAND random function to generate a four digit, and then through the slice reference transfer, set the number that users can input, and finally traverse the slice of four digits and the […]

  • Using go zero to quickly implement JWT authentication in go


    You can have a look at what JWT isOfficial websiteIn a word, it is a stateless authentication scheme for servers, and it is also the most popular cross domain authentication solution. To achieve JWT authentication, we need to divide it into the following two steps The client obtains the JWT token. JWT token authentication brought […]