Answer the question
In order to leave comments, you need to log in
Problem creating package. What to do with GOPATH?
Hello. I'm trying to create a package, but the following problem has occurred:
There is a math.go file in the /home/car/projects/pack1/math directory when I type go install, as shown in the article: golang-book.ru/chapter-11-packages gives the following error : "go install: no install location for directory /home/car/projects/pack1/math outside GOPATH. For more details see: go help gopath."
go env output:
GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/car/projects"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build226767196=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
Если указать: export GOPATH=/home/car/projects/pack1/math ошибка та же.
Как это возможно исправить?
Answer the question
In order to leave comments, you need to log in
откройте новую консоль
cd /home/car/projects/
export GOARCH=amd64
export GOROOT=/usr/local/go
export GOPATH=`pwd`
mkdir src
mv pack1 ./src/
cd src/pack1
go install
Внутри папки projects у вас должна быть папка src, а уже в ней папки с пакетами.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question