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
x/tools/cmd/bundle: discards some comments #20548
Comments
That file is autogenerated. The original one has a comment explaining what's going on https://github.com/golang/net/blob/a8e8f92cd65f5ff48599999fa4001d9b95ecea85/http2/server.go#L400
I guess the bundle script removes comments. |
I understand.
Why does the bundle script strip some comments and not others?
Loosing part of the comments is another layer of indirection for external project users & contributors, it serves no useful purpose.
Raphael
… Le 1 juin 2017 à 17:52, Alberto Donizetti ***@***.***> a écrit :
That file is autogenerated. The original one has a comment explaining what's going on
https://github.com/golang/net/blob/a8e8f92cd65f5ff48599999fa4001d9b95ecea85/http2/server.go#L400 <https://github.com/golang/net/blob/a8e8f92cd65f5ff48599999fa4001d9b95ecea85/http2/server.go#L400>
if sc.tlsState.ServerName == "" {
// Client must use SNI, but we don't enforce that anymore,
// since it was causing problems when connecting to bare IP
// addresses during development.
//
// TODO: optionally enforce? Or enforce at the time we receive
// a new request, and verify the the ServerName matches the :authority?
// But that precludes proxy situations, perhaps.
//
// So for now, do nothing here again.
}
I guess the bundle script removes comments.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#20548 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AC4Kev_hTC4vZXAG_RDb177Bxr72R7aIks5r_t5XgaJpZM4NtKp3>.
|
The bundle godoc (https://godoc.org/golang.org/x/tools/cmd/bundle) says that comments may not be preserved. I assume this is to save lines of code, since you can quickly end up with very large files. It does seem to keep comments that serve as godoc for package members, though. I believe the |
Closing this, since 1) apparently there's no issue with the code 2) as mvdan says, autogenerated files are not really supposed to be readable and the header points to the original source |
I'm going to reopen this and repurpose it towards fixing the bundle too. I think @alandonovan, do you know why we're losing some comments but only a few? |
I fully agree, the documentation policy in that file should be one or the other.
Also I discover this bundle thing for the first time but do not understand why we can’t directly import in http the needed library : isn’t it http2? Importing it may be a cleaner way than copy/pasting code through a script, and would remove 1 level of indirection when analyzing code. But I am surely missing another constraint for which bundle still is the solution.
Raphael
… Le 7 juin 2017 à 20:03, Brad Fitzpatrick ***@***.***> a écrit :
I'm going to reopen this and repurpose it towards fixing the bundle too.
I think h2_bundle.go should be readable or totally gibberish, not halfway in the middle. But I'd prefer readable since we're 95% of the way there.
@alandonovan <https://github.com/alandonovan>, do you know why we're losing some comments but only a few?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#20548 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AC4Keqr2KYKC6f9scqzYLBF2xikoCRCGks5sBuXagaJpZM4NtKp3>.
|
Go doesn't permit circular dependencies so we can't have net/http import http2, since http2 already depends on net/http (for types, etc). |
Wow I missed that one. That’s a large quantity of non-trivial code. In my case I was trying to cleanup a faulty http2 configuration, being linked directly against your http2 package would have made my exploration less painful : human-size files separated by concept, clear delineation between http-generic and http2-specific concepts, ...
With aliases you could resolve that by moving the common part to a deeper net/httpbase package, and, to continue providing the Go1 API guarantees, alias them in net/http.
I am generally biased against aliases (indirection), but if I had to choose, I would prefer aliases over bundling.
Raphael
… Le 7 juin 2017 à 20:18, Brad Fitzpatrick ***@***.***> a écrit :
Go doesn't permit circular dependencies so we can't have net/http import http2, since http2 already depends on net/http (for types, etc).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#20548 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AC4KegQLwCYe1Rl0cozf0IFWVWwMSf7Bks5sBulYgaJpZM4NtKp3>.
|
I'm not sure yet why bundle is losing some comments, but the way in which comments are associated with syntax nodes has always been a weak aspect of the design of the Deleting all comments is not an option because several kinds of special comment have semantics in the compiler. |
Maybe @griesemer could help. |
i.e., this is a known problem. As @adonovan pointed out, comment handling is a weak spot in the I haven't looked at There is (somewhat tedious) way to address this: The [begin, end[ source interval for each declaration node can be used to determine all the comments that belong to the declaration. That list of comments, together with the declaration node, may be be bundled up in a Leaving for somebody else to pick this up. |
/cc @fatih @hirochachacha (if either of you are interested in helping) |
CL https://golang.org/cl/45117 mentions this issue. |
@bradfitz I'll take a look at it. |
oops, seems like @hirochachacha was faster than me :) |
It seems printer package already addressed @griesemer 's suggestion. |
CL https://golang.org/cl/45158 mentions this issue. |
The golang.org/x/tools/cmd/bundle tool previously had a bug where it dropped some comments. This regenerates it with the fixed version (https://golang.org/cl/45117). (Upstream is still git rev 3470a06c1, from https://golang.org/cl/44331) Updates #20548 Change-Id: Ic5d9208a0c8f7facdb7b315c6acab66ace34c0a9 Reviewed-on: https://go-review.googlesource.com/45158 Reviewed-by: Hiroshi Ioka <hirochachacha@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.3 darwin/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/raphaelgeronimi/Local/Sabrina"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.8.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.8.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yv/6zwrsm6j6kqgj6vr3hf0_zbw0000gn/T/go-build481562037=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
I looked at http/h2_bundle.go code
What did you expect to see?
No empty if...then blocks
What did you see instead?
In http2Server.ServeConn, there is a useless if...then block around lines 3173-3181:
This empty block looks strange, beyond being useless, I dont know if this could create a security issue. The empty line within the next if...then block right below looks strange too.
This also stresses the need to increase linters usage within the go project itself. There are linters which report that kind of error, it's surprising that they are used in most golang projects but still not used within the core project itself.
The text was updated successfully, but these errors were encountered: