• How does golang install third party packages? Installation of third party package tools in golang


    How to install a third-party package in golang? For some reasons, such as the official website of golang, we have no way to access it. There are some problems in using it golang.org/x/tools This kind of bag can’t get directly golang.org/x/tools Next, let’s take the installation of tools as an example to give you a […]

  • Installing golang’s SDK in Debian system


    Go (also known as “golang“) is the second open source programming language released by Google in 2009. Since its birth, it has several design principles: simplicity, safety and speed. The go language distribution has a variety of debugging, testing, tuning, and code review tools. Nowadays, go language and its tool chain are available in the […]

  • Analysis of golang regular expression


    Go (also known as golang) is a static, strongly typed and compiled language developed by Robert Griesemer, rob pike and Ken Thompson of Google. The syntax of go language is similar to that of C, but its functions include: memory security, GC (garbage collection), structure and CSP style concurrent computing. Robert Griesemer, rob pike and […]

  • Examples of golang unit testing and coverage


    1 Overview C / C + + and Java (as well as most of the mainstream programming languages) have their own mature unit testing frameworks, the former such as check, the latter such as JUnit, but these programming frameworks are still third-party products in essence. In order to execute unit testing, we have to build […]

  • Delve in golang is too low to debug


    Problem description analysis This is due to the low version of the local delve component. In 2019.2.1, GoLand supports go 1.13 by default Check if there is a problem in the directory F: (go (gopath directory) github.com/go -Delve / delve / CMD / DLV, and it also exists in the bin directory dlv.exe File, executed […]

  • Examples of how golang uses gomodule to manage go dependencies in public test environment


    Background: the best way of debugging service is to directly practice on the computer. For employees in the company, collaborative development on the same set of services should feel better than development in a separate environment. Problems can be found and solved together, and requirements can be developed together.However, the company’s test machine is often […]

  • Explain the basic use of golang iris framework in detail


    Iris introduction Write once and run anywhere with minimal machine power, such as Android, IOS, Linux and windows. It supports Google Go and can be implemented on all platforms with only one executable service. Iris is known for its simple and powerful API. In addition to the low-level access that iris provides you. Iris is […]

  • Talking about the use of defer in golang


    order This paper mainly studies the definition of golang defer Return first assigns a value (for the named return value), then executes defer, and finally returns the function The order of execution of the defer function calls is opposite to that of the defer statements to which they belong The expression after defer can be […]

  • Analysis of the underlying implementation principle of map in golang language


    In the process of development, map is an essential data structure. In golang, using map will encounter different experiences from other languages, such as accessing nonexistent elements, returning null values of their types, the size of the map, why the error “cannot take the address of” is reported, and the randomness of traversing the map.This […]

  • Connecting MySQL database in golang


    To connect mysql database in golang, you need to use a third-party class librarygithub.com/go-sql-driver/mysqlIn this class library, MySQL connection pool is implemented, and only two parameters need to be set Generally, you need to call MySQL first sql.Open Function, but at this time did not really connect to MySQL, but only created a DB object. […]

  • Example code for golang to send HTTP get request


    Using the standard library HTTP to achieve package tools import ( “io/ioutil” “net/http” ) func Get(url string)string{ res, err :=http.Get(url) if err != nil { return “” } robots, err := ioutil.ReadAll(res.Body) res.Body.Close() if err != nil { return “” } return string(robots) } The above is the detailed content of the sample code of […]

  • Implementation of etcd access and numerical monitoring by golang


    The test code is as follows package main import ( “fmt” “log” “time” “go.etcd.io/etcd/clientv3” “golang.org/x/net/context” ) var ( dialTimeout = 5 * time.Second requestTimeout = 2 * time.Second endpoints = []string{“”, “”, “”} ) func main() { cli, err := clientv3.New(clientv3.Config{ Endpoints: endpoints, DialTimeout: dialTimeout, }) if err != nil { log.Fatal(err) } defer cli.Close() […]