1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-11-23 22:36:11 +02:00

feat: add more info to --version

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos A Becker
2021-12-17 16:39:55 -03:00
parent 18272c80e0
commit a2d91a501a

View File

@@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"runtime"
"runtime/debug"
"github.com/goreleaser/goreleaser/cmd"
@@ -37,6 +38,7 @@ func buildVersion(version, commit, date, builtBy string) string {
if builtBy != "" {
result = fmt.Sprintf("%s\nbuilt by: %s", result, builtBy)
}
result = fmt.Sprintf("%s\ngoos: %s\ngoarch: %s", result, runtime.GOOS, runtime.GOARCH)
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {
result = fmt.Sprintf("%s\nmodule version: %s, checksum: %s", result, info.Main.Version, info.Main.Sum)
}