github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/internal/version/version.go (about)

     1  package version
     2  
     3  import (
     4  	"runtime"
     5  	"strings"
     6  )
     7  
     8  var (
     9  	Art = `
    10  _____.___.     .__           .__.__        
    11  \__  |   |__ __|  |__ _____  |__|__| ____  
    12   /   |   |  |  \  |  \\__  \ |  |  |/    \ 
    13   \____   |  |  /   Y  \/ __ \|  |  |   |  \
    14   / ______|____/|___|  (____  /__|__|___|  /
    15   \/                 \/     \/           \/ 
    16   `
    17  	AppName = "Yuhaiin" // ユハイイン 郵便配達員 ゆうびんはいたついん
    18  	// Version can be set at link time by executing
    19  	// the command: `git describe --abbrev=0 --tags HEAD`
    20  	Version string
    21  
    22  	// GitCommit can be set at link time by executing
    23  	// the command: `git rev-parse --short HEAD`
    24  	GitCommit string
    25  
    26  	BuildArch string
    27  	BuildTime string
    28  )
    29  
    30  func String() string {
    31  	if Version == "" {
    32  		Version = "Not Released Version"
    33  	}
    34  
    35  	str := strings.Builder{}
    36  
    37  	str.WriteString(AppName)
    38  	str.WriteByte('\n')
    39  	str.WriteString("version: ")
    40  	str.WriteString(Version)
    41  	str.WriteByte('\n')
    42  
    43  	str.WriteString("commit: ")
    44  	str.WriteString(GitCommit)
    45  	str.WriteByte('\n')
    46  
    47  	str.WriteString("build arch: ")
    48  	str.WriteString(BuildArch)
    49  	str.WriteByte('\n')
    50  
    51  	str.WriteString("build time: ")
    52  	str.WriteString(BuildTime)
    53  	str.WriteByte('\n')
    54  
    55  	str.WriteString("go version: ")
    56  	str.WriteString(runtime.Version())
    57  	str.WriteByte('\n')
    58  
    59  	return str.String()
    60  }