github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/metadata/version.go (about) 1 /* 2 * Copyright (C) 2018 The "MysteriumNetwork/node" Authors. 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 package metadata 19 20 import ( 21 "fmt" 22 23 "github.com/mysteriumnetwork/terms/terms-go" 24 ) 25 26 // Version comes from BUILD_VERSION env variable (set via linker flags) 27 var Version = "" 28 29 const versionSummaryFormat = `Mysterium Node 30 Version: %s 31 Build info: %s 32 33 %s 34 %s` 35 36 // VersionAsString returns all defined version constants as single string 37 func VersionAsString() string { 38 if Version != "" { 39 return Version 40 } 41 42 version := "source" 43 if len(BuildCommit) >= 8 { 44 version += "." + BuildCommit[:8] 45 } else if BuildNumber != "" { 46 version += "." + BuildNumber 47 } 48 return version 49 } 50 51 // VersionAsSummary returns overview of current program's version 52 func VersionAsSummary(licenseCopyright string) string { 53 return fmt.Sprintf( 54 versionSummaryFormat, 55 VersionAsString(), 56 BuildAsString(), 57 licenseCopyright, 58 string(terms.TermsNodeShort), 59 ) 60 }