Go single test series 2 - network test

This is the first in a series of tutorials on Go language unit testing from zero to slip. It introduces how to use httptest and gock tools for network testing. In the previous "Go single test series 1 - Fundamentals of unit testing", we introduced the basic content of unit testing written in Go language. The business scenarios in actu ...

Posted by dougp23 on Tue, 01 Feb 2022 17:41:18 +0100

Come on, here are the Go language implementations of 23 design patterns

Abstract: Design Pattern is a set of code design experience that is repeatedly used, known by most people, classified and catalogued. The purpose of using Design Pattern is to reuse code, make code easier to be understood by others and ensure code reliability. This article is shared from Huawei cloud community< Come on, here are the Go la ...

Posted by psychohagis on Tue, 01 Feb 2022 15:22:20 +0100

Golang high concurrency processing model

Original link: https://mp.weixin.qq.com/s/ZqfN8UlWRpoGhznGH-L1mw introduce I came across an article written in 15 years. To be honest, the title really attracted me. I won't translate this article directly. I put the original address at the end of the article. The requirement of the project is very simple. The client sends the request and t ...

Posted by Anyaer on Tue, 01 Feb 2022 13:41:31 +0100

Raise a chestnut gorpc - Encoding and decoding of messages

The first rpc in 2022, earlier than ever... Stay in Hangzhou for the New Year... Write something Initialize project gorpc With go module we can easily create a new project mkdir gorpc go mod init github.com/taadis/gorpc // output: go: creating new go.mod: module github.com/taadis/gorpc Message conventions The communication between the client ...

Posted by webbnino on Tue, 01 Feb 2022 08:28:52 +0100

Go language file operation

Opening and closing of files Like C language, the operation of files in Go language is also through a FILE structure type file struct { pfd poll.FD name string dirinfo *dirInfo } type File struct { *file // os specific } Open function func Open(name string) (file *File, err error)Open opens a file for reading Close function ...

Posted by csousley on Tue, 01 Feb 2022 01:38:07 +0100

bgo: make it easier to build go programs

bgoIn a word: bgo manages exe regardless of libprefaceBefore the preface: The preface is very long and can be skipped directly.bgo It is a build assistant tool. It is not much different from the known tools for building go applications. It can support cross compiling and building go application executable files in your working environment. &lt ...

Posted by SGTWhitelaw on Mon, 31 Jan 2022 10:42:18 +0100

Implementation of decision tree algorithm by Golang

1, Algorithm Introduction    Decision Tree is a decision analysis method to obtain the probability that the expected value of net present value is greater than or equal to zero, evaluate the project risk and judge its feasibility by forming a Decision Tree on the basis of knowing the occurrence probability of various situations. It i ...

Posted by anler on Mon, 31 Jan 2022 09:13:32 +0100

Understand the elegant restart and update of the service

When the server program is updated or restarted, if we directly kill -9 the old process and start the new process, there will be the following problems: The server will directly exit the old process if the connection request is not finishedWhen a new request is called, the service has not been restarted, resulting in connection rejectedEven to ...

Posted by mcovalt on Mon, 31 Jan 2022 02:10:00 +0100

Take you ten days to easily handle the Go micro service series (VIII. Service monitoring)

preface We will show you a go zero micro service example in detail through a series of articles. The whole series is divided into ten articles, and the directory structure is as follows: Environment construction Service splitting User services Product service Order service Payment services RPC service Auth authentication Service monitoring (th ...

Posted by rcoursey on Sun, 30 Jan 2022 09:50:26 +0100

Go language slices are wiped out. Don't be confused with Java syntax

preface I always want to find out what kind of technical article is a good article? Because it is not easy to write an article that you are willing to read in the future, you can only strive for this goal for the time being. Recently, I started to brush some questions with Go and encountered some detailed problems related to slicing. Here is a ...

Posted by ozone on Sun, 30 Jan 2022 08:41:50 +0100