decred.org/dcrwallet/v3@v3.1.0/version/version_buildinfo.go (about) 1 // Copyright (c) 2021 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 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 }