Location: new project folder goroot: go installation root proxy: https://goproxy.io ,direct
Important: https://goproxy.io Is the proxy address for downloading go packages. After setting, you can normally download go warehouse / GitHub packages in China.
Create a go file
Created a test.go
Download packages required for installation
Here is a demo to install MySQL driver package: github.com/go-sql-driver/mysql
Direct import shows that the package cannot be found. Use the command line tool at the bottom left to install MySQL driver
Use the go get command to install the package
Use go get github.com/go-sql-driver/mysql to install MySQL driver. After successful installation, the imported package in test.go turns green.
I have installed it once. Some information should appear in the command window for the first installation.
Supplement: Golan uses tips of go modules
Run go mod tidy with an error:
go: golang.org/x/[email protected]: unrecognized import path “golang.org/x/sys” (https fetch: Get https://golang.org/x/sys?go-get=1: dial tcp 220.127.116.11:443: c
onnectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed
go: error loading module requirements
The reason is that some dependencies are blocked in China. You can set a proxy here to solve the problem:
Enter the setting interface of Golan, file / settings / go / go module (VGO), and set the proxy as: https://goproxy.io 。
The above is my personal experience. I hope I can give you a reference, and I hope you can support developpaer. If you have any mistakes or don’t consider completely, please don’t hesitate to comment.