Mac downloads go and installs the gin framework, and successfully runs the local project on vs code

Download (remember not to use brew, brew will fail many times inexplicably)

Download go address: https://golang.google.cn/dl/

After downloading, double-click to install the pkg package to enter the automatic installation

 

 After the installation is complete, check the version go version

View configuration go env

Start downloading the gin framework

go get -u github.com/gin-gonic/gin

 

go run main.go prompts that the current directory cannot find go.mod
to create a go module, use go mod init + package name

However, the download of the gin framework always reports an error, and the download is unsuccessful. You need to set up a proxy. First, enable the go module support

Modify the env configuration

go env -w GO111MODULE=auto 
go env -w GOPROXY=https://goproxy.cn,direct

 After downloading the startup project, an error is reported

Download library dependencies (packages not found in the error report must be downloaded again)

git clone https://github.com/protocolbuffers/protobuf-go.git

 

git clone https://github.com/golang/tools.git

 

git clone https://github.com/golang/crypto.git

 

git clone https://github.com/go-playground/locales.git

 

git clone https://github.com/golang/net.git
git clone https://github.com/golang/text.git
git clone https://github.com/leodido/go-urn.git

 

 

git clone https://github.com/pelletier/go-toml.git

Focus on explaining sse and sys download problem 1. sse problem

cd /Users/macuser/go/src/github.com/gin-contrib

If you encounter the above problem, remember to switch the directory first, and then download

cd /Users/macuser/go/src/golang.org/x

After the download is successful, just move the mov to the specified directory

mv /Users/macuser/go/src/golang.org/x /Users/macuser/go/src/github.com/gin-contrib

Two.sys problem

cd /Users/macuser/go/src/golang.org/x

git clone https://github.com/golang/sys.git

last entered project

runs successfully and outputs the browser

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_33665793/article/details/128769555