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
proposal: cmd/go: stop special-casing the "documentation" package #28162
Comments
This special case is documented at https://golang.org/cmd/go/#hdr-Package_lists_and_patterns, in the third paragraph from the end:
It's also mentioned in
In 2015, there was issue #11801 asking if this special case was still worth having or could be removed, and while there was some interest in removing it (see #11801 (comment)), the decision made was to document it and keep it (see #11801 (comment) and CL 17954). I think we should reconsider the decision for Go 2. This issue is a good place to do so. |
@dmitshur Thanks for tracking this down. I had a vague memory that this used to be there for command documentation, but I couldn't remember the details. We really don't need this mechanism anymore. Regarding the documentation you cited:
It seems to me that such documentation could just as well be in some other file not ending in |
I don't think that's possible under the Go 1 compatibility guarantee. |
The v2 version of |
@cznic I agree that this is iffy, but I don't think it's out of line with things we've done before. The files can't contain any actual code, just documentation. I'm not clear on whether that documentation will even show up anywhere. So at best, you just delete the useless file, and at worst you change the package declaration. Yes, that means people might conceivably need to do a little work, but there is recent precedent -- the addition of the WASM port in 1.11 forced people to rename files named _js.go. I wouldn't advocate for this if the feature had widespread usage, but it clearly doesn't. I think it's worth considering. |
I don't believe we can change this. It will invalidate old packages. Let's just accept it and move on. It's not hurting much. Duplicate of #11801. |
At the most, we could tie this to recognizing a newer Go version for a module tree and then change the behavior in new modules. But we'd have to keep the old logic around indefinitely for old trees. It doesn't seem worth introducing the irregularity of a special case at this point. |
cmd/go and various libraries have a special case for files that say they're in the "documentation" package. This special case is not mentioned in any user-facing documentation that I can find. It's not used in any of the runtime/stdlib, and across all of GitHub it's only used once: https://github.com/golang/protobuf/blob/master/protoc-gen-go/doc.go.
This feature seems to date back to before Go 1.0, maybe before the go tool existed. Nobody I talked to knew what it was for. I think it should be removed at least for Go 2. Given the lack of usage, I think even Go 1 might be justifiable.
@griesemer
The text was updated successfully, but these errors were encountered: