[Go advanced basic characteristics] defer

defer is a keyword we often use. It will execute the incoming function before the current function returns. It is often used to close file descriptors, close database connections and unlock resources.Usage scenarioRelease resourcesThis is the most common usage of defer, including releasing mutex, closing file handle, closing network connection, ...

Posted by robster on Fri, 08 Apr 2022 12:06:39 +0300

go language learning - array, string and slice (to be continued)

arrayThe array of Go language is a value type. Although the elements of the array can be modified, the assignment of the array itself and the transfer of function parameters are handled in the way of overall replication.Definition methodvar a [3]int // Define an int array with a length of 3, and all elements are 0 var b = [.. ...

Posted by PRodgers4284 on Fri, 08 Apr 2022 05:04:39 +0300

On the limitations of Go 1.18 generics

preface After go version 1.18, generics was officially introduced, which is called type parameters. This paper briefly introduces the use of generics in go. For a long time, go has no concept of generics. Only the interface occasionally acts as a generic. However, the interface can not meet some basic Generic requirements. For example, in this ...

Posted by phrygius on Thu, 07 Apr 2022 13:23:59 +0300

Practice GoF's design pattern: Singleton pattern

Singleton mode can also realize polymorphism. If you predict that the singleton may be extended in the future, you can design it as an abstract interface to make the client rely on abstraction. In this way, there is no need to change the client program during future expansion. The design of network is also very simple. A hash table maintains th ...

Posted by helloise on Thu, 07 Apr 2022 07:16:13 +0300

New feature of Go 1.18: multi module workspace mode

Absrtact: Go 1.18 launched the multi module workspace mode to support multiple workspaces of modules. Let's see what's special. This article is shared from Huawei cloud community< Let's take a look at the multi module workspace mode of the new features of Go 1.18 >, author: a drop in the universe. introduction In 2022, the Go team release ...

Posted by nemonoman on Wed, 06 Apr 2022 06:53:42 +0300

Implementation principle and source code analysis of timer in Go

Please state the source of reprint ~, this article is posted on luozhiyun's blog: https://www.luozhiyun.com The source code of go used in this article is 15.7. It should be noted that the timer is revised due to version 1.14, but there is no great difference between versions 1.14 and 1.15 I wrote an article about the time wheel during the Spri ...

Posted by slipperyfish on Wed, 06 Apr 2022 01:38:08 +0300

Random notes of Go knowledge points

1. Structure (using structure to implicitly realize object-oriented) 1) Use '.' regardless of the structure type or pointer to the structure As selector 2) Structure factory (Convention: the name of the factory starts with new or new) is actually the constructor of the structure. After constructing the structure factory, you can prohibit the ...

Posted by LightningSt on Tue, 05 Apr 2022 17:32:49 +0300

golang kafka message queue based log collection project

logagent of configuration file 1. Read the configuration file and use ini to load the package of the configuration file Note that you should pay attention to "tag" when creating structure reflection configuration file, otherwise it cannot be mapped type Config struct {    KafkaConfig `ini:"kafka"`    CollectConfig `ini:"collect"` } ...

Posted by davejj on Tue, 05 Apr 2022 17:16:29 +0300

Kind deploys Karmada multi cluster management

What is karma? Karmada is a cloud native project of CNCF. Its main capability is to manage multiple Kubernetes clusters and distribute the resource objects based on the native Kubernetes to multiple clusters. For some Deployment, Job and other workload with computing resource requirements, the specific copy number scheduling ability allows dif ...

Posted by bravo81 on Tue, 05 Apr 2022 10:49:44 +0300

Talk about three transmission protocols and implementation of Git

Absrtact: as we all know, Git is the most popular distributed version control system at present. In recent two years, due to the rapid development of DevOps, everything code is becoming a standard practice. All this needs to be controlled by a configuration management center. Git has undoubtedly become a favorite in this field. In our daily dev ...

Posted by Spudgun on Tue, 05 Apr 2022 00:07:00 +0300