set the qlogged quic-go version when building the interop runner image

This commit is contained in:
Marten Seemann
2021-02-07 19:57:42 +08:00
parent 218b204e1b
commit 0437acd41d
2 changed files with 13 additions and 3 deletions

View File

@@ -18,9 +18,15 @@ import (
"github.com/francoispqt/gojay"
)
// Setting of this only works when quic-go is used as a library.
// When building a binary from this repository, the version can be set using the following go build flag:
// -ldflags="-X github.com/lucas-clemente/quic-go/qlog.quicGoVersion=foobar"
var quicGoVersion = "(devel)"
func init() {
if quicGoVersion != "(devel)" { // variable set by ldflags
return
}
info, ok := debug.ReadBuildInfo()
if !ok { // no build info available. This happens when quic-go is not used as a library.
return
@@ -29,7 +35,11 @@ func init() {
if d.Path == "github.com/lucas-clemente/quic-go" {
quicGoVersion = d.Version
if d.Replace != nil {
quicGoVersion += " (replaced)"
if len(d.Replace.Version) > 0 {
quicGoVersion = d.Version
} else {
quicGoVersion += " (replaced)"
}
}
break
}