@@ -35,41 +35,44 @@ func createBuildInfo() commands.BuildInfo {
35
35
Date : date ,
36
36
}
37
37
38
- if buildInfo , available := debug .ReadBuildInfo (); available {
39
- info .GoVersion = buildInfo .GoVersion
40
-
41
- if date == "" {
42
- info .Version = buildInfo .Main .Version
43
-
44
- var revision string
45
- var modified string
46
- for _ , setting := range buildInfo .Settings {
47
- // The `vcs.xxx` information is only available with `go build`.
48
- // This information is are not available with `go install` or `go run`.
49
- switch setting .Key {
50
- case "vcs.time" :
51
- info .Date = setting .Value
52
- case "vcs.revision" :
53
- revision = setting .Value
54
- case "vcs.modified" :
55
- modified = setting .Value
56
- }
57
- }
38
+ buildInfo , available := debug .ReadBuildInfo ()
39
+ if ! available {
40
+ return info
41
+ }
58
42
59
- if revision == "" {
60
- revision = "unknown"
61
- }
43
+ info .GoVersion = buildInfo .GoVersion
62
44
63
- if modified == "" {
64
- modified = "?"
65
- }
45
+ if date == "" {
46
+ info .Version = buildInfo .Main .Version
66
47
67
- if info .Date == "" {
68
- info .Date = "(unknown)"
48
+ var revision string
49
+ var modified string
50
+ for _ , setting := range buildInfo .Settings {
51
+ // The `vcs.xxx` information is only available with `go build`.
52
+ // This information is not available with `go install` or `go run`.
53
+ switch setting .Key {
54
+ case "vcs.time" :
55
+ info .Date = setting .Value
56
+ case "vcs.revision" :
57
+ revision = setting .Value
58
+ case "vcs.modified" :
59
+ modified = setting .Value
69
60
}
61
+ }
70
62
71
- info .Commit = fmt .Sprintf ("(%s, modified: %s, mod sum: %q)" , revision , modified , buildInfo .Main .Sum )
63
+ if revision == "" {
64
+ revision = "unknown"
72
65
}
66
+
67
+ if modified == "" {
68
+ modified = "?"
69
+ }
70
+
71
+ if info .Date == "" {
72
+ info .Date = "(unknown)"
73
+ }
74
+
75
+ info .Commit = fmt .Sprintf ("(%s, modified: %s, mod sum: %q)" , revision , modified , buildInfo .Main .Sum )
73
76
}
74
77
75
78
return info
0 commit comments