readBuildSHA returns the VCS SHA, if it's from an unmodified VCS state.
()
| 288 | |
| 289 | // readBuildSHA returns the VCS SHA, if it's from an unmodified VCS state. |
| 290 | func readBuildSHA() (_ string, ok bool) { |
| 291 | buildInfo, ok := debug.ReadBuildInfo() |
| 292 | if !ok { |
| 293 | return "", false |
| 294 | } |
| 295 | |
| 296 | var sha string |
| 297 | for _, s := range buildInfo.Settings { |
| 298 | switch s.Key { |
| 299 | case "vcs.revision": |
| 300 | sha = s.Value |
| 301 | case "vcs.modified": |
| 302 | if s.Value != "false" { |
| 303 | return "", false |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | return sha, sha != "" |
| 308 | } |
| 309 | |
| 310 | // isStdLib checks if the current execution is for stdlib. |
| 311 | func isStdLib(args []string) bool { |