-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
qlog the quic-go version #3033
qlog the quic-go version #3033
Conversation
This only works when quic-go is used as a library.
Codecov Report
@@ Coverage Diff @@
## master #3033 +/- ##
==========================================
- Coverage 86.14% 86.05% -0.09%
==========================================
Files 135 135
Lines 9458 9472 +14
==========================================
+ Hits 8147 8151 +4
- Misses 952 961 +9
- Partials 359 360 +1
Continue to review full report at Codecov.
|
qlog/qlog.go
Outdated
if d.Path == "github.com/lucas-clemente/quic-go" { | ||
quicGoVersion = d.Version | ||
if d.Replace != nil { | ||
quicGoVersion += " (replaced)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the module that replaces quic-go has a version, you could just show its version. one could replace quic-go with an older version of itself to force a downgrade, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Added.
if !ok { // no build info available. This happens when quic-go is not used as a library. | ||
return | ||
} | ||
for _, d := range info.Deps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also check the case where quic-go is the main module, and has a version.
this will be rather niche, but it could happen with e.g. go test github.com/lucas-clemente/quic-go/...
from another module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that's a case that we really need to cover.
// -ldflags="-X github.com/lucas-clemente/quic-go/qlog.quicGoVersion=foobar" | ||
var quicGoVersion = "(devel)" | ||
|
||
func init() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this func should be a no-op if quickGoVersion is not (devel). otherwise you can overwrite the explicit ldflags value with the implicit runtime/debug version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
bc11fda
to
0437acd
Compare
Using
runtime/debug.ReadBuildInfo()
only works when quic-go is used as a library, so that's almost good enough for us. For the interop runner image, we can manually set the version string usingldflags
.Thanks to @mvdan for pointing me towards
BuildInfo
!