isLocalBuild reports whether the binary came from a working tree rather than an official release. `go run` leaves version "dev"; `make install` injects `git describe --tags --always --dirty`, so a dirty tree carries a "-dirty" suffix, a clean tree past the last tag the describe shape (v0.3.0-5-g5290
(version string)
| 130 | // silently swap unreleased work for the last published release (its hash |
| 131 | // never matches the manifest, so it always reads as "stale") on first launch. |
| 132 | func isLocalBuild(version string) bool { |
| 133 | if version == "dev" || strings.HasSuffix(version, "-dirty") { |
| 134 | return true |
| 135 | } |
| 136 | // describe-with-commits: anything carrying a "-g<hex>" suffix. |
| 137 | if i := strings.LastIndex(version, "-g"); i >= 0 && isHex(version[i+2:]) { |
| 138 | return true |
| 139 | } |
| 140 | // bare `--always` short sha (tag-less clone): all-hex, no tag structure. |
| 141 | return len(version) >= 7 && isHex(version) |
| 142 | } |
| 143 | |
| 144 | // isHex reports whether s is non-empty lowercase hex, the shape of a git |
| 145 | // abbreviated commit hash. |