H
H
Hotpotatoes2016-08-17 18:46:59
go
Hotpotatoes, 2016-08-17 18:46:59

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

2 answer(s)
Владимир, 2016-08-17
@Hotpotatoes

откройте новую консоль

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

Александр Павлюк, 2016-08-17
@pav5000

Внутри папки projects у вас должна быть папка src, а уже в ней папки с пакетами.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question