| 1 | package internal |
| 2 | |
| 3 | import ( |
| 4 | "runtime/debug" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
| 8 | // Version represents the current version of dasel. |
| 9 | // The real version number is injected at build time using ldflags. |
| 10 | var Version = "development" |
| 11 | |
| 12 | func init() { |
| 13 | // Version is set by ldflags on build. |
| 14 | if Version != "development" { |
| 15 | // Strip the "v" prefix to normalize version output across build methods. |
| 16 | // The Dockerfile passes the raw git tag (e.g. "v3.10.1") while Homebrew |
| 17 | // passes the bare semver (e.g. "3.10.1"). |
| 18 | Version = strings.TrimPrefix(Version, "v") |
| 19 | return |
| 20 | } |
| 21 | |
| 22 | info, ok := debug.ReadBuildInfo() |
| 23 | if !ok { |
| 24 | return |
| 25 | } |
| 26 | |
| 27 | // https://github.com/golang/go/issues/29228 |
| 28 | if info.Main.Version == "(devel)" || info.Main.Version == "" { |
| 29 | return |
| 30 | } |
| 31 | |
| 32 | Version += "-" + info.Main.Version |
| 33 | } |