You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/go: work when binaries are available but source is missing #2775
After building from the tip @ commit a461bcce05f6 which fixed this issue, I have a new
issue while trying to go install libraries from or into my GOPATH. I think I've managed
to isolate the circumstances under which this happens.
My GOPATH package dir is:
/home/ganderson/go/pkg/linux_amd64
First, here's what actually works.
As long as there are no binary packages installed to ~/go/pkg then I can go build any
package whose source is located in ~/go/src:
☿ ganderson@excession [17:48:09] ~/src/go/golang on default at tip?
: go build -v github.com/ha/doozer
code.google.com/p/goprotobuf/proto
github.com/kr/pretty.go
github.com/ha/doozer
I can successfully go install a single package which has no dependancies:
☿ ganderson@excession [17:48:12] ~/src/go/golang on default at tip?
: go install -v github.com/kr/pretty.go/
github.com/kr/pretty.go
No here is where things start to break. Once I try to build or install a package which
has a dependency already installed as a package, the command fails... Here is the
structure of ~/go/pkg after the previous install command:
☿ ganderson@excession [17:52:27] ~/src/go/golang on default at tip?
: tree ~/go/pkg/linux_amd64/
/home/ganderson/go/pkg/linux_amd64/
└── github.com
└── kr
└── pretty.go.a
2 directories, 1 file
Now if I try to either go build or go install a package which has
github.com/kr/pretty.go as a dependency the command fails, e.g.
☿ ganderson@excession [17:54:01] ~/src/go/golang on default at tip?
: go build -v github.com/ha/doozer
code.google.com/p/goprotobuf/proto
github.com/ha/doozer
# github.com/ha/doozer
../../../go/src/github.com/ha/doozer/conn.go:7: can't find import: "github.com/kr/pretty.go"
If I clean my ~/go/pkg dir and try to go install github.com/ha/doozer directly:
☿ ganderson@excession [17:55:55] ~/src/go/golang on default at tip?
: go install -v github.com/ha/doozer
code.google.com/p/goprotobuf/proto
github.com/kr/pretty.go
github.com/ha/doozer
# github.com/ha/doozer
../../../go/src/github.com/ha/doozer/conn.go:4: can't find import: "code.google.com/p/goprotobuf/proto"
Note that both pretty.go and protobuf are both compiled and installed to ~/go/pkg during
the command but trying to build doozer against these fails.
ganderson@excession [17:58:26] ~/src/go/golang on default at tip?
: tree ~/go/pkg/linux_amd64/
/home/ganderson/go/pkg/linux_amd64/
├── code.google.com
│ └── p
│ └── goprotobuf
│ └── proto.a
└── github.com
└── kr
└── pretty.go.a
5 directories, 2 files
To summarise the issue - I can go build or go install packages in GOPATH, as long as a
dependency is not already installed to $GOPATH/pkg. This issue does *not* appear to
affect GOROOT.
I think one of your commits this week has resolved this, none of the issues I previously
reported are showing in weekly.2012-03-04. All packages are building ok whether its via
source or pre-built binary in GOPATH.
This issue has re-appeared again in go1 release. It happens for all packages that import
a third party lib which is installed as as a binary only. The symptoms as described in
comment #3 fit exactly the problem as noticed in go1 release.
The previous release where this does not happen is weekly.2012-03-22
Sorry, a further clarification. If source is available the build completes. What I am
seeing then is that it's not possible to build using third party imports where the
import is installed only as binary package in either $GOROOT or $GOPATH:
• ganderson@excession [01:05:33] ~
: tree $GOPATH/pkg
/home/ganderson/go/pkg
└── linux_amd64
├── code.google.com
│ └── p
│ └── goprotobuf
│ ├── proto.a
│ └── protoc-gen-go
│ ├── descriptor.a
│ ├── generator.a
│ └── plugin.a
└── github.com
└── kr
└── pretty.a
7 directories, 5 files
• ganderson@excession [02:44:53] ~
: go build -x -v github.com/ha/doozer...
WORK=/tmp/go-build734680617
conn.go:4:2: import "code.google.com/p/goprotobuf/proto": cannot find package
conn.go:7:2: import "github.com/kr/pretty": cannot find package
I removed support for this shortly before Go 1, because it was causing worse problems.
My intention is to allow this usage in Go 1.1, but only if there is no src directory
in the GOPATH tree in question. That is, if you create a directory listed in GOPATH
that has _no source at all_, then it will be treated as binary-only.
This issue was one of the most serious limitations of the "Distributed Systems" course
[1] at Carnegie Mellon University.
Quote:
"You can't hand out precompiled library code and use the go build tools
This was one of the most serious limitations we encountered. We tried several (hacky)
approaches and none worked reliably enough for the class environment (we need to try the
mtime hack again on AFS). This meant that we had no way to hand out binary reference
code for the students to test against. Nor could we hand out reference implementations
for students who couldn't get part of the project working." [2]
[1]: http://www.cs.cmu.edu/~dga/15-440/F12/index.html
[2]: http://da-data.blogspot.se/2013/02/teaching-distributed-systems-in-go.html
how will vendoring work in this context. One can argue that vendoring is already a half baked solution, but with this proposal ignoring vendoring it seems yet another burden to be solved. Concrete case: package A depends on package BinOnly, how does package C which vendors package A works?
the proposal says that code in the Go files is optional. This basically breaks any editor that has to work with source code. To examples that I have in mind are the Go plugin for IntelliJ which relies on the source code in GOPATH/src to work and the other is go-code which uses .a files to work. If I understand correctly, the proposal says that .a files are considered to be binary? If this is the case it means that the IntelliJ plugin will have to start parsing .a files as well, which would be ok but the do those packages include documentation for the exported types as well? Also, where's the documentation describing the .a file format (and please don't point me to the spurce code doing the work, that is not proper documentation / description)?
what will be the packaging for this? Like I've mentioned earlier, if this uses .a then some things will still be possible but if the files are going to be true compiled binaries then how does it work (with the above two concerns)
how does the binary package works for keeping it compatible between Go version? If I ship a Go 1.7 compiled binary will that work in 1.8?
this feels rushed in into 1.7. Would you consider waiting for 1.8 to have a proper discussion around it?
This feature is not intended for general use. It is intended for the very specific case of "company X wants to sell company Y a binary version of a package (or the less commercial setting from @dave-andersen: teacher X wants to give student Y a reference solution)". I've heard from multiple, diverse sources that this is already happening today, with hacks of various kinds (see background in doc). We can't stop this from happening, but we can make sure that those people don't get stuck on Go 1.4 because the go command has gotten too good at noticing the source code is missing.
To answer the question "what about tool X that needs source?", as mentioned in the doc the answer is "tool X will not work with such packages, and hopefully that will help limit the use of such things." In particular this makes no sense in any open source context such as "go get" or Linux distributions, which is why for example "go get" will not support such arrangements. But again Go is used for more than just open source.
I'm happy to say the details here are experimental in case other details arise (not that the tools are covered by the compatibility guarantee anyway) or somehow it's not restrictive enough and starts to be used inappropriately, but there is a real need here, just one felt disproportionally by people outside the open source community and not on GitHub.
The IntelliJ plugin can stay as it is, or it might make sense to use go/types reading the binaries anyway, depending on the exact needs of the plugin. But it's fine if it doesn't work with binary-only packages. The more helpful tools that don't support binary-only packages and discourage their use, the better. But they do need to work for actually building a program.
Again, I'm not against this feature landing in the Go distribution, I can see the benefits of having it.
However, Go, unlike C, doesn't have header files (at least until now).
From my understanding of the phrase:
Having a “fake” version of the source code also provides a way to supply documentation compatible with “go doc” and “godoc” even though the complete source code is missing.
It does seem that one will need to provide a minimal definition of the package, something like:
// Copyright 2016 dlsniper//go:binary-only-packagepackage awesome
// This is entirely optional// The Awesomizer interface allows you to make awesome codetypeAwesomizerinterface{
CodeIt()
}
At which point I would rather prefer to enforce the stub package to contain the public definitions (and hopefully documentation for this) rather than just the package name and the special flag + other build flags. This would then mean that the documentation of the package has to be respected and it would help out users using such packages.
Speaking of flags, rather than introduce a new flag for the go tool, wouldn't it be better to introduce a new, static build tag? It can keep the name binary-only-package but then as a developer I could at least test out how this works in the code and still have the code for the package as well. This would also represent one less thing that Go developers have to learn and keep track of (not everyone knows the //go: flags (and yes, I know of go:generate)
Again, to address the 🐘 in the issue: what about vendoring? How would that work in this context? There are already problems with the current vendoring approach which came up a few times on the mailing list and have only resulted in workarounds / "developers should learn more / read / understand better" which is not very real-life unfortunately. Adding a binary only as a vendored dependency, even if internally, would not be something that people will skip, I'm positive this will happen.
The more helpful tools that don't support binary-only packages and discourage their use, the better.
I'm willing to wage a bet that within a couple of weeks of this feature landing people will ask for this feature to work. And like I've said, maybe for the IntelliJ plugin will do some support for it (or not, I can't speak of that right now) but if it's there, people will want to use it (as you've said, they already do it) as it would be a standard feature (which is exactly why people have editors like Atom, VSCode or IntelliJ with all sorts of plugins helping them write the code. But I don't wan to digress here on how people write code).
To sum up, imho:
public types should be present in the stub Go package (which is expected to be delivered apparently from the proposal)
vendoring needs to be addressed before merging this, not after (even if it means clear documentation of the use-cases and how to approach them)
maybe build tags could be used instead of the //go:binary-only "flag" or how we call those
Thank you.
EDIT:
I've changed the build flag to build tag, sorry for the wrong names.
There's also of course the issue of ensuring that the binary package being compiled is the one that the authors intended to distribute so maybe having a checksum for the binary present in the stub package would help the go tool to validate it at compile time?
This has been an issue since 1.5 and has been ignored since then (it has
always been "we will address in release N+1"). Kicking the can down the
road has proven to not be helpful. What is nice about what Russ has
implemented is that the owner of such code can pick the level of
interoperability they desire. They can provide the minimal:
//go:binary-only-package
package mine
Or they can provide more useful information:
//go:binary-only-package
// Package mine implements our secret Sauce.
package mine
// A Value contains information about a value.
type Value struct {
Name string // name of the value
_ struct{}
}
// Int returns the integer value of v.
func (v *Value) Int() int
// Mine is a super secret function that takes
// x and produces y using the confidential
// Sauce function:
func Mine(x Value) (y Value)
This will actually work with go doc:
$ go doc
package mine // import "c"
func Mine(x Value) (y Value)
type Value struct { ... }
$ go doc Mine
func Mine(x Value) (y Value)
Mine is a super secret function that takes x and produces y using the
confidential Sauce function:
$ go doc Value
type Value struct {
Name string // name of the value
// Has unexported fields.
}
A Value contains information about a value.
func Mine(x Value) (y Value)
func (v *Value) Int() int
I don't think the latter needs to be required, though I would hope most
producers would include more detail than less. Perhaps someone will even
write a tool that takes full source code, strips out everything not needed
by go doc, and adds the //go:binary-only-package comment to the top.
Adding checksums is interesting, but in this case I would venture to say
that versioning is more useful as it will immediately tell you which
version is more up to date.
I really thank Russ for doing this as I have been one of those affected by
the deteriorating "support" for binary only packages (as a consumer, not a
producer). I think he has implemented a solution that has the least impact
and is the easiest to move forward with new features, if needed. Once out
there, those who need binary only, non-open source packages will be able to
tell us how well it is working and if there are changes that should be
made. I think breaking how this works between releases is still better
than the status-quo. Being called experimental is fine, as long as it
satisfies the primary goal (making it possible to release binary only
packages).
This feature is not intended for general use. It is intended for the
very specific case of "company X wants to sell company Y a binary version
of a package (or the less commercial setting from @dave-andersen https://github.com/dave-andersen: teacher X wants to give student Y a
reference solution)". I've heard from multiple, diverse sources that this
is already happening today, with hacks of various kinds (see background in
doc). We can't stop this from happening, but we can make sure that
those people don't get stuck on Go 1.4 because the go command has gotten
too good at noticing the source code is missing.
To answer the question "what about tool X that needs source?", as
mentioned in the doc the answer is "tool X will not work with such
packages, and hopefully that will help limit the use of such things." In
particular this makes no sense in any open source context such as "go get"
or Linux distributions, which is why for example "go get" will not support
such arrangements. But again Go is used for more than just open source.
I'm happy to say the details here are experimental in case other details
arise (not that the tools are covered by the compatibility guarantee
anyway) or somehow it's not restrictive enough and starts to be used
inappropriately, but there is a real need here, just one felt
disproportionally by people outside the open source community and not on
GitHub.
The IntelliJ plugin can stay as it is, or it might make sense to use
go/types https://goto.google.com/types reading the binaries anyway,
depending on the exact needs of the plugin. But it's fine if it doesn't
work with binary-only packages. The more helpful tools that don't support
binary-only packages and discourage their use, the better. But they do need
to work for actually building a program.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #2775 (comment)
This has been an issue since 1.5 and has been ignored since then (it has always been "we will address in release N+1"). Kicking the can down the road has proven to not be helpful.
@pborman to be a bit mean, that's what they do with generics for the last 6 years, no? Not to mention other issues (multiple package coverage, etc...) I don't want to go there but this is not a technical argument for a good implementation of a solution imho.
They can provide the minimal [...] Or they can provide more useful information [...]
So why not force those who want this feature to do proper documentation / packaging for it? @rsc says that it's ok to make it painful for end-users, why not make it painful (and get real value of it) for producers as well?
Adding checksums is interesting, but in this case I would venture to say that versioning is more useful as it will immediately tell you which version is more up to date.
We don't want to have go get aware on versioning so why would binary only packages be different? Also checksums provide a different functionality than versioning.
I really thank Russ for doing this as I have been one of those affected by the deteriorating "support" for binary only packages (as a consumer, not a producer).
I too am grateful for his work and all the other contributors to the Go ecosystem, don't get me wrong. But like I've stated, this feels bad. I agree with what @robpike suggested to flag it as experimental. Meanwhile we could still discuss about this, no?
I feel I don't stress enough for this. I'm not against the idea of having this implemented, not even a bit. I'm against the idea of rushing it to get in for 1.7 just because it's something people are doing today. Vendoring has more problems and I can argue that it's a problem for more people than binary-only packages are. I don't want to force this comparison anymore but this doesn't sound inline with the Go vision of offering pragmatic solutions for problems people have.
I've raised a few points to at least have a decent discussion on how to solve them and, if solutions are found then I don't see any problem for getting this into 1.7.
I don't think anyone has said "no, it should not be marked experimental".
That is a fine idea. One really nice thing about the solution is that if
you don't need binary-only packages then you will not notice this at all.
If you do need binary-only packages, you will be very grateful that this is
part of 1.7. This will also make Go more appealing for commercial
products. The GNU C compiler was going nowhere fast (in the commercial
world) until RMS relented and introduced the LGPL.
This has been an issue since 1.5 and has been ignored since then (it has
always been "we will address in release N+1"). Kicking the can down the
road has proven to not be helpful.
@pbormanhttps://github.com/pborman to be a bit mean, that's what they
do with generics for the last 6 years, no? Not to mention other issues
(multiple package coverage, etc...) I don't want to go there but this is
not a technical argument for a good implementation of a solution imho.
At least generics work as well today as they did in 1.4.2 and 1.0 :-) I
can't really say that about binary only package releases.
The reason this is being "rushed" into 1.7 is because it was not done for
1.6 after 1.5 broken the existing recipes, and people are being held back
to 1.4.2. This is something I have had discussions about with various
members of the Go team since 1.5. There have been issues filed about it.
It seems you are saying that Russ did not go far enough and those questions
(how to make go get work, how does IntelliJ work with it, what about
vendoring) must be answered before anything goes in. I disagree, I think
Russ took the appropriate minimal solution for 1.7. All those other things
can be discussed and addressed once we have more experience. I don't think
it would be possible to get a good answer for vendoring at this point as
the vendoring we have already has enough questions. I can see an easy
possible answer to vendoring, but it assumes that binary-only packages are
freely redistributable, but I don't think that will be the case. You are
correct that that vendoring needs more thought.
So, by all means, let's mark it experimental, let's have more discussions
and debates, but let's not let those things from precluding this common
sense minimal solution for 1.7. Right now it feels that the discussion has
been how to put up roadblocks to getting this minimal solution into 1.7.
I submitted the CL. We will note that it is experimental in the release notes.
To reply briefly to some points:
It doesn't work to be a build tag. Build tags are about selection of files to compile, not about changing the meaning of the compilation. Independent concerns, independent mechanisms. And //go: for prefixes is the established standard for source annotations directed at the go toolchain (but we're not going to retroactively change // +build).
If the binary-only package has the wrong imports inside it, likely the best way to address that would be to go back to the person who sold you the package and get them fixed. But you could also rewrite the binary form to change import paths if needed. I am skeptical it will come to that. And note that if you're happy with the imports being used in the binary-only package, you can choose your own import path for it simply by moving it somewhere else in the file system.
I don't think there's anything interesting about vendoring here except that it's one rationale for wanting a different import path.
If any tools want to not support these binary blobs, that's fine with me: you can say "go get doesn't support them either."
Activity
rsc commentedon Jan 30, 2012
Comment 1:
Labels changed: added go1-must.
rsc commentedon Mar 1, 2012
Comment 2:
This issue was closed by revision b03a5f6.
Status changed to Fixed.
gnanderson commentedon Mar 2, 2012
Comment 3:
After building from the tip @ commit a461bcce05f6 which fixed this issue, I have a new issue while trying to go install libraries from or into my GOPATH. I think I've managed to isolate the circumstances under which this happens. My GOPATH package dir is: /home/ganderson/go/pkg/linux_amd64 First, here's what actually works. As long as there are no binary packages installed to ~/go/pkg then I can go build any package whose source is located in ~/go/src: ☿ ganderson@excession [17:48:09] ~/src/go/golang on default at tip? : go build -v github.com/ha/doozer code.google.com/p/goprotobuf/proto github.com/kr/pretty.go github.com/ha/doozer I can successfully go install a single package which has no dependancies: ☿ ganderson@excession [17:48:12] ~/src/go/golang on default at tip? : go install -v github.com/kr/pretty.go/ github.com/kr/pretty.go No here is where things start to break. Once I try to build or install a package which has a dependency already installed as a package, the command fails... Here is the structure of ~/go/pkg after the previous install command: ☿ ganderson@excession [17:52:27] ~/src/go/golang on default at tip? : tree ~/go/pkg/linux_amd64/ /home/ganderson/go/pkg/linux_amd64/ └── github.com └── kr └── pretty.go.a 2 directories, 1 file Now if I try to either go build or go install a package which has github.com/kr/pretty.go as a dependency the command fails, e.g. ☿ ganderson@excession [17:54:01] ~/src/go/golang on default at tip? : go build -v github.com/ha/doozer code.google.com/p/goprotobuf/proto github.com/ha/doozer # github.com/ha/doozer ../../../go/src/github.com/ha/doozer/conn.go:7: can't find import: "github.com/kr/pretty.go" If I clean my ~/go/pkg dir and try to go install github.com/ha/doozer directly: ☿ ganderson@excession [17:55:55] ~/src/go/golang on default at tip? : go install -v github.com/ha/doozer code.google.com/p/goprotobuf/proto github.com/kr/pretty.go github.com/ha/doozer # github.com/ha/doozer ../../../go/src/github.com/ha/doozer/conn.go:4: can't find import: "code.google.com/p/goprotobuf/proto" Note that both pretty.go and protobuf are both compiled and installed to ~/go/pkg during the command but trying to build doozer against these fails. ganderson@excession [17:58:26] ~/src/go/golang on default at tip? : tree ~/go/pkg/linux_amd64/ /home/ganderson/go/pkg/linux_amd64/ ├── code.google.com │ └── p │ └── goprotobuf │ └── proto.a └── github.com └── kr └── pretty.go.a 5 directories, 2 files To summarise the issue - I can go build or go install packages in GOPATH, as long as a dependency is not already installed to $GOPATH/pkg. This issue does *not* appear to affect GOROOT.gnanderson commentedon Mar 2, 2012
Comment 4:
rsc commentedon Mar 2, 2012
Comment 5:
Owner changed to builder@golang.org.
Status changed to Accepted.
gnanderson commentedon Mar 5, 2012
Comment 6:
rsc commentedon Mar 7, 2012
Comment 7:
Status changed to Retracted.
gnanderson commentedon Apr 2, 2012
Comment 8:
gnanderson commentedon Apr 2, 2012
Comment 9:
gnanderson commentedon Apr 2, 2012
Comment 10:
Sorry, a further clarification. If source is available the build completes. What I am seeing then is that it's not possible to build using third party imports where the import is installed only as binary package in either $GOROOT or $GOPATH: • ganderson@excession [01:05:33] ~ : tree $GOPATH/pkg /home/ganderson/go/pkg └── linux_amd64 ├── code.google.com │ └── p │ └── goprotobuf │ ├── proto.a │ └── protoc-gen-go │ ├── descriptor.a │ ├── generator.a │ └── plugin.a └── github.com └── kr └── pretty.a 7 directories, 5 files • ganderson@excession [02:44:53] ~ : go build -x -v github.com/ha/doozer... WORK=/tmp/go-build734680617 conn.go:4:2: import "code.google.com/p/goprotobuf/proto": cannot find package conn.go:7:2: import "github.com/kr/pretty": cannot find packagersc commentedon Apr 2, 2012
Comment 11:
Labels changed: added priority-later, go1.1, removed priority-go1, go1-must.
Status changed to Accepted.
rsc commentedon Dec 10, 2012
Comment 12:
Labels changed: added size-l.
davecheney commentedon Jan 9, 2013
Comment 13:
Issue #4635 has been merged into this issue.
mewmew commentedon Feb 12, 2013
Comment 14:
davecheney commentedon Feb 12, 2013
Comment 15:
Owner changed to ---.
42 remaining items
gopherbot commentedon Apr 25, 2016
CL https://golang.org/cl/22433 mentions this issue.
gopherbot commentedon Apr 25, 2016
CL https://golang.org/cl/22432 mentions this issue.
dlsniper commentedon Apr 26, 2016
Hi,
I have a few issues with this proposal:
.afiles to work. If I understand correctly, the proposal says that.afiles are considered to be binary? If this is the case it means that the IntelliJ plugin will have to start parsing.afiles as well, which would be ok but the do those packages include documentation for the exported types as well? Also, where's the documentation describing the.afile format (and please don't point me to the spurce code doing the work, that is not proper documentation / description)?.athen some things will still be possible but if the files are going to be true compiled binaries then how does it work (with the above two concerns)robpike commentedon Apr 26, 2016
I agree it seems rushed. Perhaps it should be marked as an experimental feature that will soak for one cycle before becoming official.
rsc commentedon Apr 26, 2016
This feature is not intended for general use. It is intended for the very specific case of "company X wants to sell company Y a binary version of a package (or the less commercial setting from @dave-andersen: teacher X wants to give student Y a reference solution)". I've heard from multiple, diverse sources that this is already happening today, with hacks of various kinds (see background in doc). We can't stop this from happening, but we can make sure that those people don't get stuck on Go 1.4 because the go command has gotten too good at noticing the source code is missing.
To answer the question "what about tool X that needs source?", as mentioned in the doc the answer is "tool X will not work with such packages, and hopefully that will help limit the use of such things." In particular this makes no sense in any open source context such as "go get" or Linux distributions, which is why for example "go get" will not support such arrangements. But again Go is used for more than just open source.
I'm happy to say the details here are experimental in case other details arise (not that the tools are covered by the compatibility guarantee anyway) or somehow it's not restrictive enough and starts to be used inappropriately, but there is a real need here, just one felt disproportionally by people outside the open source community and not on GitHub.
The IntelliJ plugin can stay as it is, or it might make sense to use go/types reading the binaries anyway, depending on the exact needs of the plugin. But it's fine if it doesn't work with binary-only packages. The more helpful tools that don't support binary-only packages and discourage their use, the better. But they do need to work for actually building a program.
dlsniper commentedon Apr 26, 2016
Thanks for feedback.
Again, I'm not against this feature landing in the Go distribution, I can see the benefits of having it.
However, Go, unlike C, doesn't have header files (at least until now).
From my understanding of the phrase:
It does seem that one will need to provide a minimal definition of the package, something like:
At which point I would rather prefer to enforce the stub package to contain the public definitions (and hopefully documentation for this) rather than just the package name and the special flag + other build flags. This would then mean that the documentation of the package has to be respected and it would help out users using such packages.
Speaking of flags, rather than introduce a new flag for the go tool, wouldn't it be better to introduce a new, static build tag? It can keep the name
binary-only-packagebut then as a developer I could at least test out how this works in the code and still have the code for the package as well. This would also represent one less thing that Go developers have to learn and keep track of (not everyone knows the//go:flags (and yes, I know ofgo:generate)Again, to address the 🐘 in the issue: what about vendoring? How would that work in this context? There are already problems with the current vendoring approach which came up a few times on the mailing list and have only resulted in workarounds / "developers should learn more / read / understand better" which is not very real-life unfortunately. Adding a binary only as a vendored dependency, even if internally, would not be something that people will skip, I'm positive this will happen.
I'm willing to wage a bet that within a couple of weeks of this feature landing people will ask for this feature to work. And like I've said, maybe for the IntelliJ plugin will do some support for it (or not, I can't speak of that right now) but if it's there, people will want to use it (as you've said, they already do it) as it would be a standard feature (which is exactly why people have editors like Atom, VSCode or IntelliJ with all sorts of plugins helping them write the code. But I don't wan to digress here on how people write code).
To sum up, imho:
//go:binary-only"flag" or how we call thoseThank you.
EDIT:
I've changed the build flag to build tag, sorry for the wrong names.
dlsniper commentedon Apr 26, 2016
There's also of course the issue of ensuring that the binary package being compiled is the one that the authors intended to distribute so maybe having a checksum for the binary present in the stub package would help the go tool to validate it at compile time?
pborman commentedon Apr 26, 2016
This has been an issue since 1.5 and has been ignored since then (it has
always been "we will address in release N+1"). Kicking the can down the
road has proven to not be helpful. What is nice about what Russ has
implemented is that the owner of such code can pick the level of
interoperability they desire. They can provide the minimal:
//go:binary-only-package
package mine
Or they can provide more useful information:
//go:binary-only-package
// Package mine implements our secret Sauce.
package mine
// A Value contains information about a value.
type Value struct {
Name string // name of the value
_ struct{}
}
// Int returns the integer value of v.
func (v *Value) Int() int
// Mine is a super secret function that takes
// x and produces y using the confidential
// Sauce function:
func Mine(x Value) (y Value)
This will actually work with go doc:
$ go doc
package mine // import "c"
func Mine(x Value) (y Value)
type Value struct { ... }
$ go doc Mine
func Mine(x Value) (y Value)
Mine is a super secret function that takes x and produces y using the
confidential Sauce function:
$ go doc Value
type Value struct {
Name string // name of the value
// Has unexported fields.
}
A Value contains information about a value.
func Mine(x Value) (y Value)
func (v *Value) Int() int
I don't think the latter needs to be required, though I would hope most
producers would include more detail than less. Perhaps someone will even
write a tool that takes full source code, strips out everything not needed
by go doc, and adds the //go:binary-only-package comment to the top.
Adding checksums is interesting, but in this case I would venture to say
that versioning is more useful as it will immediately tell you which
version is more up to date.
I really thank Russ for doing this as I have been one of those affected by
the deteriorating "support" for binary only packages (as a consumer, not a
producer). I think he has implemented a solution that has the least impact
and is the easiest to move forward with new features, if needed. Once out
there, those who need binary only, non-open source packages will be able to
tell us how well it is working and if there are changes that should be
made. I think breaking how this works between releases is still better
than the status-quo. Being called experimental is fine, as long as it
satisfies the primary goal (making it possible to release binary only
packages).
On Tue, Apr 26, 2016 at 7:06 AM, Russ Cox notifications@github.com wrote:
dlsniper commentedon Apr 26, 2016
@pborman to be a bit mean, that's what they do with generics for the last 6 years, no? Not to mention other issues (multiple package coverage, etc...) I don't want to go there but this is not a technical argument for a good implementation of a solution imho.
So why not force those who want this feature to do proper documentation / packaging for it? @rsc says that it's ok to make it painful for end-users, why not make it painful (and get real value of it) for producers as well?
We don't want to have
go getaware on versioning so why would binary only packages be different? Also checksums provide a different functionality than versioning.I too am grateful for his work and all the other contributors to the Go ecosystem, don't get me wrong. But like I've stated, this feels bad. I agree with what @robpike suggested to flag it as experimental. Meanwhile we could still discuss about this, no?
I feel I don't stress enough for this. I'm not against the idea of having this implemented, not even a bit. I'm against the idea of rushing it to get in for 1.7 just because it's something people are doing today. Vendoring has more problems and I can argue that it's a problem for more people than binary-only packages are. I don't want to force this comparison anymore but this doesn't sound inline with the Go vision of offering pragmatic solutions for problems people have.
I've raised a few points to at least have a decent discussion on how to solve them and, if solutions are found then I don't see any problem for getting this into 1.7.
pborman commentedon Apr 26, 2016
I don't think anyone has said "no, it should not be marked experimental".
That is a fine idea. One really nice thing about the solution is that if
you don't need binary-only packages then you will not notice this at all.
If you do need binary-only packages, you will be very grateful that this is
part of 1.7. This will also make Go more appealing for commercial
products. The GNU C compiler was going nowhere fast (in the commercial
world) until RMS relented and introduced the LGPL.
On Tue, Apr 26, 2016 at 8:18 AM, Florin Pățan notifications@github.com
wrote:
At least generics work as well today as they did in 1.4.2 and 1.0 :-) I
can't really say that about binary only package releases.
The reason this is being "rushed" into 1.7 is because it was not done for
1.6 after 1.5 broken the existing recipes, and people are being held back
to 1.4.2. This is something I have had discussions about with various
members of the Go team since 1.5. There have been issues filed about it.
It seems you are saying that Russ did not go far enough and those questions
(how to make go get work, how does IntelliJ work with it, what about
vendoring) must be answered before anything goes in. I disagree, I think
Russ took the appropriate minimal solution for 1.7. All those other things
can be discussed and addressed once we have more experience. I don't think
it would be possible to get a good answer for vendoring at this point as
the vendoring we have already has enough questions. I can see an easy
possible answer to vendoring, but it assumes that binary-only packages are
freely redistributable, but I don't think that will be the case. You are
correct that that vendoring needs more thought.
So, by all means, let's mark it experimental, let's have more discussions
and debates, but let's not let those things from precluding this common
sense minimal solution for 1.7. Right now it feels that the discussion has
been how to put up roadblocks to getting this minimal solution into 1.7.
cmd/go: add Package.StaleReason for debugging with go list
rsc commentedon Apr 29, 2016
I submitted the CL. We will note that it is experimental in the release notes.
To reply briefly to some points: