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

Fix https://github.com/fortio/fortiotel/issues/149 #1

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ func normalizeVersion(version string) string {
return short
}

func getVersion(binfo *debug.BuildInfo, path string) (short, sum, mainPath, base string) {
func getVersion(binfo *debug.BuildInfo, path string) (short, sum, mainPath, base string, isMain bool) {
mainPath = binfo.Main.Path
base = normalizeVersion(binfo.Main.Version)
if path == "" || path == mainPath {
sum = binfo.Main.Sum
short = base
isMain = true
return
}
// try to find the right module in deps
Expand All @@ -71,9 +72,9 @@ func FromBuildInfoPath(path string) (short, long, full string) {
log.Print("Error calling debug.ReadBuildInfo() for fortio version module")
return
}
short, sum, mainPath, base := getVersion(binfo, path)
short, sum, mainPath, base, isMain := getVersion(binfo, path)
long = short + " " + sum + " " + binfo.GoVersion + " " + runtime.GOARCH + " " + runtime.GOOS
if short != base {
if !isMain {
long = long + " (in " + mainPath + " " + base + ")"
}
full = fmt.Sprintf("%s\n%v", long, binfo.String())
Expand Down