Go Environment Installation
Go to download
Before you can begin go development, you need to install the SDK. This section uses Windows as an example to describe the installation process.
- Go to golang.org/dl/
- Download the source code of the corresponding system
- Windows is installed using MSI. During the Windows installation process, you can choose to automatically add paths to environment variables, so that you do not need to manually configure environment variables later.
- After the installation is complete, it can be used
go env
Command to check the version status in go.
Go’s Goroot and Gopath details
- Goroot is the go installation path, which is used to find the bin directory and add bin to environment variables.
- Gopath cannot be the same as go’s installation directory because it also requires a specific file name (which conflicts with Goroot). Gopath is, understandably, the working directory. The gopath directory has three main subdirectories: SRC, for user-created projects; Bin Saves the compiled EXE file. PKG, used to store third-party extension libraries.
- Gopath is set by default to
C:/user/administrator/go/gopath
. When you need to change it, you can use the following methods:
When installing GO, it will automatically generate a user’s environment variable GOPATH, which is changed to the path we need. Then add another environment variable GOPATH to the system environment variable and set the path to be consistent. This completes the modification of the GOPATH path.
Beego installation
Bego command
The installation command is:
go get github.com/astaxie/beego
Network problems
go env -w GOPROXY=https://goproxy.io,direct
go env -w GO111MODULE=on
Copy the code
If that doesn’t work, turn off the computer and try climbing over the wall again.
Be installed
Similarly, the installation command is:
go get github.com/beego/bee
Copy the code
Install command
Matters needing attention
If you’re developing in Goland, you’ll need to manually configure the path to GOPATH yourself.