diff options
| author | Dax Raad <[email protected]> | 2025-05-30 20:47:56 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-05-30 20:48:36 -0400 |
| commit | f3da73553c45f17e04b1e77cb13eb0fca714d1bd (patch) | |
| tree | a24317a19e1ab2a89da50db669dc6894f15d00d1 /packages/tui/internal/version | |
| parent | 9a26b3058ffc1023e5c7e54b6d571c903d15888e (diff) | |
| download | opencode-f3da73553c45f17e04b1e77cb13eb0fca714d1bd.tar.gz opencode-f3da73553c45f17e04b1e77cb13eb0fca714d1bd.zip | |
sync
Diffstat (limited to 'packages/tui/internal/version')
| -rw-r--r-- | packages/tui/internal/version/version.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/tui/internal/version/version.go b/packages/tui/internal/version/version.go new file mode 100644 index 000000000..69fd5282b --- /dev/null +++ b/packages/tui/internal/version/version.go @@ -0,0 +1,25 @@ +package version + +import "runtime/debug" + +// Build-time parameters set via -ldflags +var Version = "unknown" + +// A user may install pug using `go install github.com/sst/opencode@latest`. +// without -ldflags, in which case the version above is unset. As a workaround +// we use the embedded build version that *is* set when using `go install` (and +// is only set for `go install` and not for `go build`). +func init() { + info, ok := debug.ReadBuildInfo() + if !ok { + // < go v1.18 + return + } + mainVersion := info.Main.Version + if mainVersion == "" || mainVersion == "(devel)" { + // bin not built using `go install` + return + } + // bin built using `go install` + Version = mainVersion +} |
