Home  >  Article  >  Backend Development  >  How to call golang package

How to call golang package

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-12-10 10:56:493632browse

How to call golang package

1. My GOPATH environment variable value, as shown below:

How to call golang package

2. Enter the src directory in the GOPATH path, The directory name is the starting position of the referenced package, as shown below:

How to call golang packageHow to call golang package

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.

How to call golang package

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more