`-pkgdir` option does not work with `go get` command

69 views
Skip to first unread message

QL Zhuo

unread,
Mar 31, 2017, 1:58:15 AM3/31/17
to golan...@googlegroups.com

My go workspace is simple:


[000]kdr2@Debian-X230:~/gows$ pwd
/home/kdr2/gows
[000]kdr2@Debian-X230:~/gows$ tree
.
└── src
    └── test
        └── m.go

2 directories, 1 file


And the content of m.go is from https://raw.githubusercontent.com/facebookgo/grace/master/gracedemo/demo.go . All ENV variables are set.

When I run go get -v -x test, all goes well, it downloads the dependencies and build out an executable. But when I run go get -v -x -pkgdir pkg-1 test, it leads to an error:


... mkdir -p $WORK/net/http/_obj/ cd /usr/local/go-1.8/src/net/http /usr/local/go-1.8/pkg/tool/linux_amd64/compile -o $WORK/net/http.a -trimpath $WORK -p net/http -complete -buildid 49a4487ab4c506c0ef8aa1f5f4ceea3fc8b1243d -importmap golang_org/x/net/http2/hpack=vendor/golang_org/x/net/http2/hpack -importmap golang_org/x/net/idna=vendor/golang_org/x/net/idna -importmap golang_org/x/net/lex/httplex=vendor/golang_org/x/net/lex/httplex -importmap golang_org/x/text/unicode/norm=vendor/golang_org/x/text/unicode/norm -importmap golang_org/x/text/width=vendor/golang_org/x/text/width -D _/usr/local/go-1.8/src/net/http -I $WORK -I pkg-1 -pack ./client.go ./cookie.go ./doc.go ./filetransport.go ./fs.go ./h2_bundle.go ./header.go ./http.go ./jar.go ./method.go ./request.go ./response.go ./server.go ./sniff.go ./status.go ./transfer.go ./transport.go cp $WORK/net/http.a pkg-1/net/http.a github.com/facebookgo/httpdown mkdir -p $WORK/github.com/facebookgo/httpdown/_obj/ cd /home/kdr2/gows/src/github.com/facebookgo/httpdown /usr/local/go-1.8/pkg/tool/linux_amd64/compile -o $WORK/github.com/facebookgo/httpdown.a -trimpath $WORK -p github.com/facebookgo/httpdown -complete -buildid 45d38b6b6de48eff9fe8461b5764b769ea669b4c -D _/home/kdr2/gows/src/github.com/facebookgo/httpdown -I $WORK -I pkg-1 -pack ./httpdown.go # github.com/facebookgo/httpdown src/github.com/facebookgo/httpdown/httpdown.go:16: can't find import: "github.com/facebookgo/clock" [002]kdr2@Debian-X230:~/gows$


When I run go build -v -x -pkgdir pkg-1 test, the executable can be built well, but it does not create a pkg-1 dir to place the tmp files.

So, my question is, how to use -pkgdir with go get and go build? does -pkgdir work as what its document says?

Thanks.

--
This email address (zhuo.dev<at>gmail.com) is only for development affairs, e.g. mail list, please mail to zhuo<at>hexoasis.com or zhuoql<at>zoho.com for other purpose.

ZHUO QL (KDr2), http://kdr2.com

Dave Cheney

unread,
Mar 31, 2017, 2:10:21 AM3/31/17
to golang-nuts
go build builds packages, then throws them away. I think that is why there is nothing written to the pkg-1 directory.
 

So, my question is, how to use -pkgdir with go get and go build? does -pkgdir work as what its document says?


What are you trying to do? Can you explain the problem you're trying to solve, maybe someone can suggest a different solution.

QL Zhuo

unread,
Mar 31, 2017, 3:12:12 AM3/31/17
to golang-nuts
Thank you Dave, I think go build would create the dir `pkg-1` during the building, but it didn't.

My problem is `how to recompile all the source code`, and after a discussion at https://forum.golangbridge.org/t/pkgdir-option-does-not-work-with-go-get-command/5020/ it becomes to another: is `-pkgdir` really a available option?

--
This email address (zhuo.dev<at>gmail.com) is only for development affairs, e.g. mail list, please mail to zhuo<at>hexoasis.com or zhuoql<at>zoho.com for other purpose.

ZHUO QL (KDr2), http://kdr2.com

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Cheney

unread,
Mar 31, 2017, 3:56:37 AM3/31/17
to golang-nuts
What is the reason you want to recompile all the source code? The go tool automatically recompiles anything that is out of date.

What is the problem you are trying to solve by using -a to force recompilation of everything.

Reply all
Reply to author
Forward
0 new messages