Tag Archives: # golang

How to Fix unexpected directory layout in go language

1. Make sure the path is set correctly </h2 b> There is a problem with the directory structure of the

project. Suggested structure:

project:
  - bin (可不需要)
  - src
    - sub-project-1
      - module1
      - module2
      - vendor
    - sub-project-2 
  - pkg (可不需要)

and appends the project directory to the environment variable GOPATH. Only one path

is saved in GOPATH

##设置环境变量
vim /etc/profile
##编辑器中首行填写如下内容,GOPATH和GOROOT根据读者自己情况修改
export GOPATH=/root/go
export GOROOT=/usr/lib/golang
export PATH=$GOPATH/bin:$PATH
##wq保存退出文件,并执行
source /etc/profile

2. Check to see if there are duplicate folders </h2 b>

in the centos directory, or GOROOT directory, it was found that SRC/had the same directory file as the project in GOPATH, after deleting it and recompiling the project in GOPATH, the problem was solved. Where XXX stands for compilation engineering project.

rm -rf /usr/lib/golang/src/XXX