From 2b5eccfb82df355b5e11210566f4313b625477f4 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 2 Feb 2024 16:45:51 +0700 Subject: [PATCH] qlog: rename qlog.go to connection_tracer.go (#4301) --- qlog/{qlog.go => connection_tracer.go} | 29 ------------------- ...qlog_test.go => connection_tracer_test.go} | 0 qlog/trace.go | 29 +++++++++++++++++++ 3 files changed, 29 insertions(+), 29 deletions(-) rename qlog/{qlog.go => connection_tracer.go} (95%) rename qlog/{qlog_test.go => connection_tracer_test.go} (100%) diff --git a/qlog/qlog.go b/qlog/connection_tracer.go similarity index 95% rename from qlog/qlog.go rename to qlog/connection_tracer.go index 39c54af796a..e9e88e88088 100644 --- a/qlog/qlog.go +++ b/qlog/connection_tracer.go @@ -6,7 +6,6 @@ import ( "io" "log" "net" - "runtime/debug" "time" "github.com/quic-go/quic-go/internal/protocol" @@ -17,34 +16,6 @@ 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/quic-go/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 - } - for _, d := range info.Deps { - if d.Path == "github.com/quic-go/quic-go" { - quicGoVersion = d.Version - if d.Replace != nil { - if len(d.Replace.Version) > 0 { - quicGoVersion = d.Version - } else { - quicGoVersion += " (replaced)" - } - } - break - } - } -} - const eventChanSize = 50 type connectionTracer struct { diff --git a/qlog/qlog_test.go b/qlog/connection_tracer_test.go similarity index 100% rename from qlog/qlog_test.go rename to qlog/connection_tracer_test.go diff --git a/qlog/trace.go b/qlog/trace.go index bb1d5bb8ff3..dcb7da6fc6c 100644 --- a/qlog/trace.go +++ b/qlog/trace.go @@ -1,6 +1,7 @@ package qlog import ( + "runtime/debug" "time" "github.com/quic-go/quic-go/internal/protocol" @@ -9,6 +10,34 @@ 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/quic-go/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 + } + for _, d := range info.Deps { + if d.Path == "github.com/quic-go/quic-go" { + quicGoVersion = d.Version + if d.Replace != nil { + if len(d.Replace.Version) > 0 { + quicGoVersion = d.Version + } else { + quicGoVersion += " (replaced)" + } + } + break + } + } +} + type topLevel struct { trace trace }