I gave up PHP.
Goland development environment setup
The development tools
In this development environment, the system uses MAC and IDE uses VScode.
Downloading the GO Software Package
You can download the installation package from the Go Chinese website and select the recommended download version. Generally, the recommended version is a stable version.
Select the go1.6.3.Darwin-AMd.pkg installation package and click Install Next.
Vscode installs Golang
Open the extended configuration of vscode and install the go plug-in
Install the GO language development kit
In vscode, press command + shift + p and type go:install/update tools to install all tools
Configuring the System Environment
The command to query the go language configuration is
go env
Copy the code
Enter the bash_profile file for configuration
vim ~/.bash_profile
export GOROOT=/usr/local/go
export GOPATH=/Users/xxx/xxx/Go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
source ~/.bash_profile
Copy the code
Perform validation
go version
go env
Copy the code
Run a simple Demo to see if it works
package main
import (
"fmt"
)
func main() {
fmt.Println("done")
}
Copy the code
GOPATH: indicates the development directory. It is recommended not to be the same as the go installation directory. This directory contains SRC, PKG, bin. Environment variables, you need to add the go/bin directory to the path path. The generated files can be directly run in GOPATH, and the PKG folder is stored after go Install and generated files that are not main functions
Problems that will be encountered
Installation failed
godef: failed to install godef(github.com/rogpeppe/godef): Error: Command failed: /usr/local/go/bin/go get -v github.com/rogpeppe/godef
This situation is due to the domestic network problems, you can change this package to install and download separately. My habit is to open the ladder during installation, but some of them still cannot be installed
You can switch to the GOPATH directory from the command line and execute
go install github.com/ramya-rao-a/go-outline@latest
go install github.com/acroca/go-symbols@latest
go install golang.org/x/tools/cmd/guru@latest
go install golang.org/x/tools/cmd/gorename@latest
go install github.com/josharian/impl@latest
go install github.com/rogpeppe/godef@latest
go install github.com/sqs/goreturns@latest
go install github.com/golang/lint/golint@latest
go install github.com/cweill/gotests/gotests@latest
Copy the code
Wait for package installation commands
The following error may also be reported during installation
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
It can be executed from the command line
xcode-select --install
Copy the code
After the installation is complete, execute the install command above to install the package.
Until vscode displays the following command, all the required plug-ins are installed
All tools successfully installed. You are ready to Go :).
Copy the code