Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: get missing packages for files with build tag #4742

Closed
matrixik opened this issue Feb 2, 2013 · 10 comments
Closed

cmd/go: get missing packages for files with build tag #4742

matrixik opened this issue Feb 2, 2013 · 10 comments
Milestone

Comments

@matrixik
Copy link

matrixik commented Feb 2, 2013

What steps will reproduce the problem?
1. Run `go get .` in directory having some files with build constraints 
// +build mysql

What is the expected output?
Download all missing packages

What do you see instead?
go get won't download missing packages if they are in files with build tag

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g

Which operating system are you using?
Windows 7 x32

Which version are you using?  (run 'go version')
go version devel +036190b86798 Sat Feb 02 12:39:04 2013 +0100 windows/386

Please provide any additional information below.
If my installation miss go-sqlite3 and mymysql (mymysql in file with build tag) packages
and I run:

go get . -tags mysql
output:
package github.com/mattn/go-sqlite3
        imports -tags: unrecognized import path "-tags"
package github.com/mattn/go-sqlite3
        imports mysql: unrecognized import path "mysql"

only go-sqlite3 is downloaded but not compiled.

Best regards,
Dobrosław Żybort
@alberts
Copy link
Contributor

alberts commented Feb 2, 2013

Comment 1:

judging by the help for go get, it doesn't understand -tags
go get -d .
go install -tags mysql .
might have done the trick?

@rsc
Copy link
Contributor

rsc commented Feb 2, 2013

Comment 2:

go get -tags mysql .
should work. I will update the help message.

@matrixik
Copy link
Author

matrixik commented Feb 3, 2013

Comment 3:

Thank you for replies.
`go get -tags mysql .` works but... I still need to use `go get .` to get go-sqlite3.
I would prefer to use one command to download all missing packages instead of two or
more.
Maybe something like `go get -alltags .` or `go get -all .` could be implemented? Or
update `go get .` to always get all missing packages from all files.
Best regards,
Dobrosław Żybort

@rsc
Copy link
Contributor

rsc commented Feb 3, 2013

Comment 4:

Unless go-sqlite3 is explicitly using // +build !mysql, I don't understand
why -tags mysql would disable its being built.

@matrixik
Copy link
Author

matrixik commented Feb 3, 2013

Comment 5:

Sorry, looks like you must misunderstood me.
I want to run `go get .` in my project source directory and it should *download*
go-sqlite3 *and* mymysql packages *same time*.
I found where is problem: build !mysql
go-sqlite3 is referenced in file with "build !mysql" tag.
mymysql is referenced in file with "build mysql" tag.
Now I need to run two commands to get both of them:
`go get -tags mysql .`
and
`go get .`
I want to use *only one command* to get both of them.
If I remove `// +build !mysql` then `go get -tags mysql .` will download both of them at
once, but I want it to allow simple `go build` build my project with sqlite support.
Best regards,
Dobrosław Żybort
P.S. Sorry if I'm wasting your time.

@rsc
Copy link
Contributor

rsc commented Feb 3, 2013

Comment 6:

go get . is installing the things you need to build the code in the current
directory.
You only need one or the other depending on the tags. It is behaving as
intended.

@rsc
Copy link
Contributor

rsc commented Feb 3, 2013

Comment 7:

This issue was closed by revision 46d6f3c.

Status changed to Fixed.

@matrixik
Copy link
Author

matrixik commented Feb 3, 2013

Comment 8:

OK, thank you for reply.
But maybe you can add additional flag '-all'?
`go get -all .`
That will download all dependencies, regardless of tags.
Best regards,
Dobrosław Żybort

@rsc
Copy link
Contributor

rsc commented Feb 3, 2013

Comment 9:

Exactly what people want will differ from project to project. -all will
never work in general.
For example it's fine to write a file like
---
// +build ignore
package main
this isn't even go code anymore

@matrixik
Copy link
Author

matrixik commented Feb 3, 2013

Comment 10:

That's make sense.
Thank you for reply and sorry for bothering.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants