Instructions for fmt.Scan in Go language

In go language, if you want to get user input, you will use scan method. There are many ways to use scan in the go language. Today I will introduce their usage and differences. Like print, scan falls into three categories: Scan, Scanf, and Scanln: read text from standard input os.Stdin (get data from terminal) Fscan, Fscanf, Fscanln: read tex ...

Added by Tux-e-do on Mon, 30 Mar 2020 17:05:17 +0300

go micro practice 01: fast build service

background Go micro provides us with a very convenient way to quickly build microservices, and we do not need to know about micro in advance. Here is a simple example to quickly implement a service. Create a Proto file Because we want to do microservices, there must be a server and a client. The format of content transmission between these two ...

Added by BMorganVA on Fri, 27 Mar 2020 12:21:40 +0200

Basic use of channel

1. Piping classification Reading and writing pipeline Read-only pipeline Write only pipes Buffered channel: Specifies the size when creating (default to non buffered channel if not specified) 2. Proper use of pipes The pipeline can read and write automatically after closing The write pipeline cannot exceed the capacity cap of the pipeline ...

Added by sfw5000 on Sun, 22 Mar 2020 09:53:15 +0200

C + + parses the required parameters according to the passed function pointer

C + + can obtain the required parameter types according to the function pointer passed in, and then obtain the required parameters according to the parameter source. Here I use tuple as a demonstration. However, as long as the actual parameters can be obtained according to the sequence number or order, similar methods can be used: First, an aux ...

Added by GBahle on Thu, 19 Mar 2020 20:48:21 +0200

Common Golang Type Conversions

** 1.Type(expression): ** int(time.Now().Weekday()) //Monday int int(time.Now().Month()) //Month to int var a float64 a = 3.1 b := int(a) //float64 to int var a int a = 1 b := int64(a) //int to int64 ** 2.strconv package: **string and int, int32, int64: i, _ := strconv.Atoi(s) //string to int s := strconv.Itoa(i) //int to string i, ...

Added by jj20051 on Sat, 07 Mar 2020 02:45:49 +0200

Gong Service for Smooth Restart Analysis

Smooth restart means that our programs can be restarted without interrupting service, seamlessly linking up old and new processes, and deploying Zero-Downtime. Smooth restart is based on elegant exit, as described in a previous article: Golang uses the Shutdown feature to gracefully summarize the exit of http services There are two main strateg ...

Added by justinjkiss on Thu, 27 Feb 2020 04:15:47 +0200

Xiaohao algorithm let you learn how to use code to judge "24" points

"24 o'clock" is a kind of mathematical game, just like chess and go, it is a kind of entertainment that people like to see. It can't be traced back to when it started, but it is gradually accepted by more and more people with its unique mathematical charm and rich connotation. Today, I'd like to share an algorithm topic about "24 ...

Added by abcd1234 on Wed, 26 Feb 2020 05:12:30 +0200

Remember a golang memory leak

Program Functions The main function of this program is to import data from files into the clickhouse database. [Problem Description] Server memory runs out at regular intervals [Problem Analysis] Because it was developed in go language, pprof, a tool popular in the industry, was used. Reference URL:https://cizixs.com/2017/09/11/profiling-golang ...

Added by Knutty on Mon, 10 Feb 2020 05:43:57 +0200

Concurrent Go Language Foundation

1.1 Concurrent and Parallel Concurrent: Perform multiple tasks at the same time (chat with multiple friends using WeChat) Parallel: Perform multiple tasks at the same time (360 in windows is antivirus, and you're also writing code) The concurrency of the Go language is achieved through goroutine.Goroutines are similar to threads and are user-f ...

Added by Thethug on Sat, 08 Feb 2020 18:34:44 +0200

The use of Go language map

The use of Go language map 1, Basic introduction to map: map is a key value data structure, also known as a field or associated array. (similar to the dictionary in Python) Basic syntax: Var map variable name map[keyType]valueType Generally, the key types are: int, string, or bool, number, pointe ...

Added by digibrain on Fri, 07 Feb 2020 13:59:24 +0200