source: code/trunk/version.go@ 825

Last change on this file since 825 was 825, checked in by root, 7 weeks ago

破壊する

File size: 1004 bytes
RevLine 
[809]1package suika
2
3import (
4 "fmt"
5 "runtime/debug"
6 "strings"
7)
8
9const (
10 defaultVersion = "0.0.0"
11 defaultBuild = "0000-01-01:00:00+00:00"
12)
13
14var (
15 // Version is the tagged release version in the form <major>.<minor>.<patch>
16 // following semantic versioning and is overwritten by the build system.
17 Version = defaultVersion
18
19 // Build is the date and time of the build as an RFC3339 formatted string
20 // and is overwritten by the build system.
21 Build = defaultBuild
22)
23
24// FullVersion display the full version and build
25func FullVersion() string {
26 var sb strings.Builder
27
[825]28 isDefault := Version == defaultVersion && Build == defaultBuild
[809]29
30 if !isDefault {
[825]31 sb.WriteString(fmt.Sprintf("%s@%s %s", Version, Build))
[809]32 }
33
34 if info, ok := debug.ReadBuildInfo(); ok {
35 if isDefault {
36 sb.WriteString(fmt.Sprintf(" %s", info.Main.Version))
37 }
38 sb.WriteString(fmt.Sprintf(" %s", info.GoVersion))
39 if info.Main.Sum != "" {
40 sb.WriteString(fmt.Sprintf(" %s", info.Main.Sum))
41 }
42 }
43
44 return sb.String()
45}
Note: See TracBrowser for help on using the repository browser.