The following tutorial column from golang will introduce to you how to correctly start a project in Goland. I hope it will be helpful to friends in need!
Because Error: cannot not find package will appear every time you create a project and build, so this article was born
GOPATH
echo $GOPATH# 如果需要更改GOPATH可以根据以下操作 (Mac)vim ~/.bash_profileexport GOPATH=#你的目标地址 #保存:wq #刷新 source ~/.bash_profile
pkg
,bin## in the
$GOAPTH folder #,
srcThree folders
mkdir $GOPATH/pkg # pkg存放编译后的包文件 mkdir $GOPATH/src # src存放项目源文件,我们的项目目录一般在该文件中 mkdir $GOPATH/bin # bin存放编译后的可执行文件
$GOAPTH |-bin |-pkg |-src |-(项目名称,之后要创建的)
Mac
vim ~/.bash_profile #打开 bash_profile # 将以下代码复制到 bash_profile 中export GO111MODUL=on # 开启 go moduleexport GOPROXY=https://goproxy.io # 设置国内代理 #保存:wq #刷新 source ~/.bash_profile
Windows
set GO111MODUL=on # 开启 go moduleset GOPROXY=https://goproxy.io # 设置国内代理,推荐使用该地址
# 输入命令 go env
Golang will automatically search for the project code in the $GOPATH
Check whether the agent is also configured in Goland
The above is the detailed content of How to start a project correctly in Goland. For more information, please follow other related articles on the PHP Chinese website!