2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-10-27 04:23:58 +00:00
|
|
|
|
|
|
|
package version
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
|
|
|
"strings"
|
2023-02-11 02:07:37 +00:00
|
|
|
|
|
|
|
"tailscale.com/types/lazy"
|
2020-10-27 04:23:58 +00:00
|
|
|
)
|
|
|
|
|
2023-02-11 02:07:37 +00:00
|
|
|
var stringLazy = lazy.SyncFunc(func() string {
|
2020-10-27 04:23:58 +00:00
|
|
|
var ret strings.Builder
|
2023-02-11 02:07:37 +00:00
|
|
|
ret.WriteString(Short())
|
2020-10-27 04:23:58 +00:00
|
|
|
ret.WriteByte('\n')
|
2023-01-13 14:15:07 +00:00
|
|
|
if IsUnstableBuild() {
|
|
|
|
fmt.Fprintf(&ret, " track: unstable (dev); frequent updates and bugs are likely\n")
|
|
|
|
}
|
2023-02-11 02:07:37 +00:00
|
|
|
if gitCommit() != "" {
|
|
|
|
fmt.Fprintf(&ret, " tailscale commit: %s%s\n", gitCommit(), dirtyString())
|
2020-10-27 04:23:58 +00:00
|
|
|
}
|
2023-02-11 02:07:37 +00:00
|
|
|
if extraGitCommitStamp != "" {
|
|
|
|
fmt.Fprintf(&ret, " other commit: %s\n", extraGitCommitStamp)
|
2020-10-27 04:23:58 +00:00
|
|
|
}
|
|
|
|
fmt.Fprintf(&ret, " go version: %s\n", runtime.Version())
|
|
|
|
return strings.TrimSpace(ret.String())
|
2023-02-11 02:07:37 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
func String() string {
|
|
|
|
return stringLazy()
|
2020-10-27 04:23:58 +00:00
|
|
|
}
|