"go run" vs. "go install" and $GOPATH

68 views
Skip to first unread message

Andrew Stewart

unread,
Sep 9, 2020, 12:30:50 PM9/9/20
to golang-nuts

Hi,

On my system "go run" creates ~/go and places pkg there, even though $GOPATH is set. Whereas "go install" places pkg under $GOPATH.

Ideally, I would like ~/go to never be created.

$ ls ~/go
ls: /Users/foo/go: No such file or directory
$ echo $GOPATH
/Users/foo/Google Drive/programming/golang/workspace
$ pwd
/Users/foo/Google Drive/programming/golang/workspace/github.com/foo/project
go: creating new go.mod: module github.com/foo/project
$ go install
go: finding module for package github.com/google/gopacket
go: finding module for package github.com/google/gopacket/pcap
go: finding module for package github.com/google/gopacket/layers
go: downloading github.com/google/gopacket v1.1.18
$ project
[...]
$ ls ~/go
ls: /Users/foo/go: No such file or directory
$ go run ./main.go 
go: downloading github.com/google/gopacket v1.1.18
[...]
$ ls ~/go
pkg
 
Thank you for any help you can provide!
Reply all
Reply to author
Forward
0 new messages