mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-06 01:14:52 +01:00
sync
This commit is contained in:
25
packages/tui/internal/version/version.go
Normal file
25
packages/tui/internal/version/version.go
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user