File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 77 "os/exec"
88 "runtime"
99 "runtime/debug"
10+ "strings"
1011)
1112
1213var (
@@ -91,6 +92,14 @@ func Init() {
9192
9293func readRevisionTime () (revision , vcsTime string ) {
9394 if info , ok := debug .ReadBuildInfo (); ok {
95+ // Rewrite version from -buildvcs info if it is valid.
96+ // Format for tagged version: v1.9.13
97+ // Format for custom commit: v1.9.14-0.20251215184105-753d6617ab58
98+ // Format for modified code: v1.9.14-0.20251215184105-753d6617ab58+dirty
99+ if s , ok := strings .CutPrefix (info .Main .Version , "v" ); ok {
100+ Version = s
101+ }
102+
94103 for _ , setting := range info .Settings {
95104 switch setting .Key {
96105 case "vcs.revision" :
@@ -103,7 +112,7 @@ func readRevisionTime() (revision, vcsTime string) {
103112 vcsTime = setting .Value
104113 case "vcs.modified" :
105114 if setting .Value == "true" {
106- revision = "mod." + revision
115+ revision + = "+dirty"
107116 }
108117 }
109118 }
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ import (
4949)
5050
5151func main () {
52+ // version will be set later from -buildvcs info, this used only as fallback
5253 app .Version = "1.9.13"
5354
5455 type module struct {
You can’t perform that action at this time.
0 commit comments