Questions tagged [gopath]

The GOPATH environment variable is used to specify directories outside of $GOROOT that contain the source for Go projects and their binaries.

See the go command and go/build package documentation for more details.

99 questions
445
votes
25 answers

What should be the values of GOPATH and GOROOT?

I'm trying to install doozer like this: $ goinstall github.com/ha/doozer I get these errors. goinstall: os: go/build: package could not be found locally goinstall: fmt: go/build: package could not be found locally goinstall: io: go/build: package…
jshen
  • 11,507
  • 7
  • 37
  • 59
100
votes
7 answers

Getting GOPATH error "go: cannot use path@version syntax in GOPATH mode" in Ubuntu 16.04

I'm unable to run go get git@github in my $GOPATH folder. Getting this error: go: cannot use path@version syntax in GOPATH mode I just want to understand why go get isn't working even though $GOPATH is configured during the…
zero
  • 2,054
  • 2
  • 14
  • 23
30
votes
5 answers

Golang project directory structure

I have some confusion regarding Golang directory structure. Base on the book The Way to Go by Ivo Balbaert, project code should be placed into src, and recommends the following directory structure. ├──src/ | ├──main.go | ├──say/ | …
goosman.lei
  • 386
  • 1
  • 3
  • 7
27
votes
6 answers

Cant find package from $GOROOT and $GOPATH

Small part of error I'm getting after trying to run go build command go build ./... trillian.pb.go:7:8: cannot find package "github.com/golang/protobuf/proto" in any of: /usr/local/go/src/github.com/golang/protobuf/proto (from $GOROOT) …
Mantas
  • 271
  • 1
  • 3
  • 3
14
votes
1 answer

removing module path in trace in go

I need to remove absolute path in the trace, that corresponds to the imported module. Even though I compile my program so: go build -gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH I still get the full path to the module file, where the panic…
gtristan
  • 355
  • 2
  • 10
10
votes
2 answers

Cannot do any go command anymore

Before it happened, what I am doing is trying to use the dep to manage my golang code dependency. What I found right now is I cannot do any command with go, even if I try to uninstall it with brew by brew uninstall go and do brew install go again.…
Mirza
  • 281
  • 1
  • 4
  • 14
9
votes
4 answers

Go error: go : go.mod file not found in current directory or any parent directory; (working on GOPATH/src)

I installed Golang and faced with go.mod file not found in current directory or any parent directory error at very first time. But I'm working on /src directory. Isn't go.mod only required if current working directory is located out of…
Han
  • 99
  • 1
  • 1
  • 4
8
votes
2 answers

Is there a way to run a Go module from another directory

I have the following project structure, outside of GOPATH. . // Project root ├── Dockerfile ├── .env ├── README.md └── src ├── main.go ├── go.mod ├── go.sum ├── internal │   ├── somepackage │   │   ├── main.go │   │   └──…
Diego ROJAS
  • 509
  • 1
  • 7
  • 14
7
votes
3 answers

how to manage GOPATH for multiple project directories

coming from a java and grails background, (and having written millions of lines of C 30 years ago), I cant see how go can be usable with a fixed gopath on windows. installing go creates this structure c:\users\me\go\scr \pkg …
John Little
  • 10,707
  • 19
  • 86
  • 158
5
votes
1 answer

Go no install location for directory outside GOPATH error when run "go get"

Simple Go project, with a external dependence: import ( "fmt" "html" "log" "net/http" "github.com/gorilla/mux" ) My path working fine for other tasks like run, build,…
racar
  • 181
  • 1
  • 13
5
votes
1 answer

Some questions regarding $GOPATH

I'm a new golang developer and I wonder why $GOPATH environment variable is needed to be set at the root of my project. If I'm working on several projects at the same time, I need to each time re-set the $GOPATH environment variable to point to a…
ufk
  • 30,912
  • 70
  • 235
  • 386
4
votes
2 answers

GOPATH environment variable not getting set in the Fish shell?

I have a ~/.config/fish/config.fish which contains the following lines: set PATH $PATH (go env GOPATH)/bin set -x GOPATH (go env GOPATH) If I simply run go env GOPATH at the command line, I get the default location (~/go): > go env…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
4
votes
3 answers

How to find a Go package installed with 'go get -u' when no $GOPATH is defined?

I'm following the gRPC Quickstart tutorial for Go, https://grpc.io/docs/quickstart/go/, and have installed gRPC using the command go get -u google.golang.org/grpc I actually haven't defined a GOPATH environment variable: > echo $GOPATH which, as I…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
4
votes
1 answer

Cannot find package in folder vendor in vscode - Golang

I cloned code here: https://github.com/kkdai/line-login-go. I deployed on heroku and ran successfully. But I get: cannot find package on VSCode Normally, if I put the project in the src directory, and set GOPATH, it will not report an error. But…
Nam Lee
  • 891
  • 1
  • 9
  • 20
4
votes
1 answer

Setting up proper Golang directory structure with git to use go build on custom packages

So I've been scratching my head at this for a couple weeks now, and after reading several source on how $ go build works and its three magic directories, /bin, /pkg, /src, it's still not very clear to me how to build Golang projects using custom…
GhostRavenstorm
  • 634
  • 3
  • 9
  • 29
1
2 3 4 5 6 7