github.com/ethersphere/bee/v2@v2.2.0/version.go (about) 1 // Copyright 2020 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package bee 6 7 import ( 8 "strconv" 9 "time" 10 ) 11 12 var ( 13 version string // automatically set semantic version number 14 commitHash string // automatically set git commit hash 15 commitTime string // automatically set git commit time 16 17 Version = func() string { 18 if commitHash != "" { 19 return version + "-" + commitHash 20 } 21 return version + "-dev" 22 }() 23 24 // CommitTime returns the time of the commit from which this code was derived. 25 // If it's not set (in the case of running the code directly without compilation) 26 // then the current time will be returned. 27 CommitTime = func() string { 28 if commitTime == "" { 29 commitTime = strconv.Itoa(int(time.Now().Unix())) 30 } 31 return commitTime 32 } 33 )