Tag:go

  • Go realizes fping function

    Time:2021-2-5

    1. What is fping Fping is a program similar to Ping. Different from Ping, you can specify multiple targets to Ping at the same time.After sending Ping packets, fping does not wait for a response, but continues to the next target 3. Concrete realization 1. Get IP segment //IP segment ‘1’,’2020-11-26 17:11:39.515 ‘,’2020-11-26 17:11:39.515’,’1.0.1.0 ‘,’1.0.3.255’,’fujian […]

  • Go memory model in detail

    Time:2021-1-19

    introduce The go memory model specifies some conditions under which the value returned by reading a variable in one goroutine can ensure that it is the value written to the variable in another goroutine. It took me three and a half hours to translate this article Happiness before (happened before) In a goroutine, read and […]

  • Implementation code of go JSON data forwarding

    Time:2021-1-16

    case For example, there is a get interface that can get user information in batches > curl ‘http://localhost:8080/user/1,2,3’ [ { “user_id”:1, “other_suff”:… }, { “user_id”:2, “other_suff”:… }, { “user_id”:3, “other_suff”:… } ] At the same time, we need to put the user information and some of their order information together to form a new interface […]

  • Exploration of in function of slice in go

    Time:2021-1-14

    Before I saw a question in Zhihu: why doesn’t golang have the same function as in Python? As a result, I searched the problem and found that many people still have such questions. Let’s talk about this topic today. In is a very common function, which may also be called contains in some languages. Although […]

  • The implementation of set in go

    Time:2021-1-13

    This article mainly describes how to use the syntax features of go language to realize the data structure of set type. demand For the data structure of set type, it is not much different from list in essence. The only reason is that set cannot contain duplicate items. Set has initialization, add, clear, remove, contains […]

  • How to use set in go

    Time:2021-1-12

    Today, let’s talk about how go uses set. This article will cover set and BitSet data structures. Data structure of go Go doesn’t have many built-in data structures. In our work, the two most commonly used data structures are slice and map, namely slice and map. In fact, there are arrays in go. The bottom […]

  • How to construct immutable data structure with go

    Time:2021-1-11

    Shared state is easy to understand and use, but it may produce obscure bugs that are hard to trace. Especially in our data structure, only part of it is passed by reference. Slicing is a good example. I will explain it in more detail later. Immutable data structure is very useful when dealing with data […]

  • How to prevent the leakage of goroutine in go

    Time:2021-1-10

    summary Go’s concurrency model is different from other languages. Although it simplifies the development of concurrent programs, if you don’t know how to use it, you will often encounter the problem of goroutine leakage. Although goroutine is a lightweight thread and takes up few resources, if it can’t be released all the time and is […]

  • Go implementation of bidirectional linked list example code

    Time:2021-1-9

    This paper introduces what is a linked list, what are the common linked lists, and then introduces where the linked list data structure can be used, and redis queue is the underlying implementation. A small example is used to demonstrate the functions of redis queue, and finally a bidirectional linked list is implemented through go. […]

  • Crud operation in mangodb using go

    Time:2021-1-5

    Before I learned the go language, I used java and SQL to operate the MySQL database in crud operation. But in my internship, the company business is using mangodb. After a period of study, I have some gains. Brief introduction of relational database and non relational database Relational database: refers to the database that uses […]

  • To solve the problem of using seed to get the same random number in go

    Time:2021-1-4

    1. Repeated random numbers No more nonsense. First of all, let’s look at a very magical phenomenon of using seed. func main() { for i := 0; i < 5; i++ { rand.Seed(time.Now().Unix()) fmt.Println(rand.Intn(100)) } } //The results are as follows // 90 // 90 // 90 // 90 // 90 If you are not […]

  • On the correct posture of digital conversion string in go

    Time:2021-1-2

    In many languages, you can easily convert any data type to a string by concatenating it to a string or using a type conversion expression. However, if you try to perform seemingly obvious operations in go (such as converting int to string), you are unlikely to get the desired results. For example: string(120) What do […]