decred.org/dcrdex@v1.0.5/dex/version/version_buildinfo.go (about) 1 // Copyright (c) 2021-2022 The Decred developers 2 // Use of this source code is governed by an ISC license 3 // that can be found at https://github.com/decred/dcrd/blob/master/LICENSE. 4 5 //go:build go1.18 6 7 package version 8 9 import "runtime/debug" 10 11 func vcsCommitID() string { 12 bi, ok := debug.ReadBuildInfo() 13 if !ok { 14 return "" 15 } 16 var vcs, revision string 17 for _, bs := range bi.Settings { 18 switch bs.Key { 19 case "vcs": 20 vcs = bs.Value 21 case "vcs.revision": 22 revision = bs.Value 23 } 24 } 25 if vcs == "" { 26 return "" 27 } 28 if vcs == "git" && len(revision) > 9 { 29 revision = revision[:9] 30 } 31 return revision 32 }