Flow control of Go language
The process control of the program determines how the program is executed. There are three main process controls:
Sequential control
Branch control
Cycle control
1, Sequential control
Sequence control is the simplest process control, which emphasizes that the code is executed from top to bottom without any sequence and jump. Note that variabl ...
Posted by RedMaster on Mon, 08 Nov 2021 14:59:56 -0800
[algorithm] sword finger Offer II 054. Sum of all values greater than or equal to nodes | 538 | 1038 (Multilingual Implementation)
Thank you very much for reading this article~ Welcome[ 👍 [like][ ⭐ Collection][ 📝 [comments]~ It's not hard to give up, but it must be cool to insist~ I hope all of us can make a little progress every day~ This paper consists of White hat of the second leader: https://le-yi.blog.csdn.net/ Blog originality~
Sword finger Offer II 05 ...
Posted by dthomas31uk on Sun, 07 Nov 2021 20:59:32 -0800
TCP sticky packet based on Go language
TCP sticky packet based on Go language
Sticky bag example
Server:
package main
import (
"bufio"
"fmt"
"io"
"net"
)
func Process2(conn net.Conn) {
defer conn.Close()
reader := bufio.NewReader(conn)
var buf [1024]byte
for {
n, err := reader.Read(buf[:])
if err == io.EOF {
break
}
if err != nil {
fmt.Println("read from clie ...
Posted by Zaid on Sun, 07 Nov 2021 10:20:59 -0800
Reflection of Go language foundation
Reflection of 09Go language foundation
Internal mechanism of variables
Variables in Go language are divided into two parts:
Type information: predefined meta information.
Value information: it can change dynamically during program operation.
Reflection introduction
Reflection refers to the ability to access and modify the program itself durin ...
Posted by sd9sd on Sat, 06 Nov 2021 19:39:52 -0700
GoLang design pattern 12 - empty object pattern
Empty object design pattern is a behavioral design pattern, which is mainly used to deal with the inspection of empty objects. Using this design pattern avoids checking empty objects. That is, in this mode, using empty objects does not cause exceptions.
The components of the empty object pattern include:
Entity: interface, which defines the me ...
Posted by gsaldutti on Sat, 06 Nov 2021 08:18:51 -0700
Conversion between go language string and numeric type
Conversion between string and int types
The conversion between string and integer is the most commonly used in our programming. Here are the specific operations
Itoa(): integer to string
The Itoa() function is used to convert int type data to the corresponding string type. The function signature is as follows
func Itoa(i int) string
Code ...
Posted by tam2000k2 on Sat, 06 Nov 2021 03:55:54 -0700
Go interview topic: talk about closure understanding in go language
Hello, I'm brother Xiao Dao.
Today's interview topic is: closure.
definition
Closure is defined in computer science as a function that references internal variables of a function.
After reading the definition, I fell into a deep thought... Indeed, if I hadn't touched closures before or didn't understand closures, this definition is really a ...
Posted by tdors on Sat, 06 Nov 2021 03:14:54 -0700
go concurrent programming Channels
preface
Channels is a type safe message queue. It acts as a pipeline between two goroutines, through which any resources will be exchanged synchronously. chan's ability to control goroutines interaction creates a Go synchronization mechanism. When the created chan has no capacity, it is called an unbuffered channel. Conversely, a chan crea ...
Posted by Sneef on Sat, 06 Nov 2021 01:24:57 -0700
Fuse principle and implementation Golang version
Dependency between services is very common in microservices. For example, the comment service depends on the audit service, and the audit service depends on the anti spam service. When the comment service calls the audit service, the audit service calls the anti spam service, and the anti spam service times out. Because the audit service depend ...
Posted by rekha on Fri, 05 Nov 2021 20:48:57 -0700
Go language Bible - Chapter 5 functions - 5.8 defined functions
Chapter 5 functions
Function allows us to package a statement sequence into a unit, and then call it many times from other parts of the program. The mechanism of function allows us to decompose a large work into small tasks. We have touched on functions before, and we will discuss more features of functions in this chapter
5.8 defined functio ...
Posted by shane0714 on Thu, 04 Nov 2021 22:23:30 -0700