1 Introduction
The go language (or Golang) is an open source programming language developed by Google. It was born on January 2, 2006 at 15:4:5 pm. It was open sourced in November 2009, and the go stable version was released in 2012. The Go language has native design advantages in multi-core concurrency. The Go language natively supports concurrency from the bottom layer, without the need for third-party libraries, developers' programming skills and development experience.
Go is a very young language, and its main goal is to "combine the development speed of dynamic languages such as Python and the performance and security of compiled languages such as C/C++"
Many companies, especially Internet companies in China, are about to or have completed the process of using the Go language to transform their old systems. The system refactored by Go language can use less hardware resources to achieve higher concurrency and I/O throughput performance. Fully tapping the potential of hardware equipment also satisfies the current market environment of refined operation.
2. Features of Go language
Concise grammar
Go language is easy to learn, with a gentle learning curve. It does not require two to three years of learning like C/C++ language. The Go language is called "the C language of the Internet age". The style of the Go language is similar to the C language. Its syntax is greatly simplified on the basis of C language, unnecessary expression brackets are removed, and the loop only has a representation method of for, which can realize various traversals such as numerical values and key values.
Unified code style
Go language provides a set of formatting tools - go fmt. Some Go language development environments or editors will use formatting tools to format the modified code when saving, so as to ensure that the code submitted by different developers is in a uniform format. (Tucao: No need to worry about those incomprehensible black magic anymore...)
High development efficiency
The Go language realizes the perfect combination of development efficiency and execution efficiency, allowing you to write C code (performance) like writing Python code (efficiency).
3. Installation
1. Download the go installation package
Official website address: https://golang.google.cn/dl/
Chinese address: https://studygolang.com/dl
Go Chinese learning documents: https://topgoer.cn/docs/golang/ golang-1ccjbpfstsfi1
download and install the package and install it to
configure the environment
After the go installation is successful, the default directory is: /usr/local/go
enter the configuration file
vim ~/.bash_profile
add configuration
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
Save, the configuration takes effect
source .bash_profile
verify
go version
go version go1.17.8 darwin/amd64
Create a go program to verify
vim test.go
package main
import "fmt"
func main(){
fmt.Println("hello world!")
}
Execute go run test.go
Finally, you can use VS Code or GoLand to code!
Follow my WeChat public
account