Home > Article > Backend Development > How to call golang package
1. My GOPATH environment variable value, as shown below:
2. Enter the src directory in the GOPATH path, The directory name is the starting position of the referenced package, as shown below:
3. Example: Here, the package of the same project is referenced, the source file "learn/main" /main.go" refers to the PrintIota method under the package "learn/lion". Here learn is the directory under src under GOPATH.
4. If the above method does not work, then the GOPATH path is incorrect, or GOPATH is disabled by other third-party package management tools, such as go.mod. For vendors, etc., you must use GOPATH to follow the above instructions. I had the problem of citing errors when my GOPATH was disabled by go.mod.
PHP Chinese website has a large number of free Golang introductory tutorials, everyone is welcome to learn!
The above is the detailed content of How to call golang package. For more information, please follow other related articles on the PHP Chinese website!