(key string)
| 30 | } |
| 31 | |
| 32 | func find(key string) (string, bool) { |
| 33 | readBuildInfo.Do(func() { |
| 34 | buildInfo, buildInfoValid = debug.ReadBuildInfo() |
| 35 | }) |
| 36 | if !buildInfoValid { |
| 37 | panic("could not read build info") |
| 38 | } |
| 39 | for _, setting := range buildInfo.Settings { |
| 40 | if setting.Key != key { |
| 41 | continue |
| 42 | } |
| 43 | return setting.Value, true |
| 44 | } |
| 45 | return "", false |
| 46 | } |
| 47 | |
| 48 | // Version returns the semantic version of the build. |
| 49 | // Use golang.org/x/mod/semver to compare versions. |