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

qlog the quic-go version #3033

Merged
merged 2 commits into from
Feb 9, 2021
Merged

qlog the quic-go version #3033

merged 2 commits into from
Feb 9, 2021

Conversation

marten-seemann
Copy link
Member

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 using ldflags.

Thanks to @mvdan for pointing me towards BuildInfo!

This only works when quic-go is used as a library.
@codecov
Copy link

codecov bot commented Feb 7, 2021

Codecov Report

Merging #3033 (0437acd) into master (622ca23) will decrease coverage by 0.09%.
The diff coverage is 28.57%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
qlog/qlog.go 91.25% <23.08%> (-3.55%) ⬇️
qlog/trace.go 90.48% <100.00%> (+0.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 622ca23...0437acd. Read the comment docs.

qlog/qlog.go Outdated
if d.Path == "github.com/lucas-clemente/quic-go" {
quicGoVersion = d.Version
if d.Replace != nil {
quicGoVersion += " (replaced)"
Copy link

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.

Copy link
Member Author

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 {
Copy link

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.

Copy link
Member Author

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() {
Copy link

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@marten-seemann marten-seemann merged commit 4e6e4db into master Feb 9, 2021
@marten-seemann marten-seemann deleted the qlog-quic-go-version branch February 9, 2021 12:26
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants