github.com/ipfans/trojan-go@v0.11.0/version/version.go (about) 1 package version 2 3 import ( 4 "flag" 5 "fmt" 6 "runtime" 7 8 "github.com/ipfans/trojan-go/common" 9 "github.com/ipfans/trojan-go/constant" 10 "github.com/ipfans/trojan-go/option" 11 ) 12 13 type versionOption struct { 14 flag *bool 15 } 16 17 func (*versionOption) Name() string { 18 return "version" 19 } 20 21 func (*versionOption) Priority() int { 22 return 10 23 } 24 25 func (c *versionOption) Handle() error { 26 if *c.flag { 27 fmt.Println("Trojan-Go", constant.Version) 28 fmt.Println("Go Version:", runtime.Version()) 29 fmt.Println("OS/Arch:", runtime.GOOS+"/"+runtime.GOARCH) 30 fmt.Println("Git Commit:", constant.Commit) 31 fmt.Println("") 32 fmt.Println("Developed by PageFault (p4gefau1t)") 33 fmt.Println("Licensed under GNU General Public License version 3") 34 fmt.Println("GitHub Repository:\thttps://github.com/ipfans/trojan-go") 35 fmt.Println("Trojan-Go Documents:\thttps://p4gefau1t.github.io/trojan-go/") 36 return nil 37 } 38 return common.NewError("not set") 39 } 40 41 func init() { 42 option.RegisterHandler(&versionOption{ 43 flag: flag.Bool("version", false, "Display version and help info"), 44 }) 45 }