github.com/tomwright/dasel@v1.27.3/internal/version.go (about)

     1  package internal
     2  
     3  import (
     4  	"runtime/debug"
     5  )
     6  
     7  // Version represents the current version of dasel.
     8  // The real version number is injected at build time using ldflags.
     9  var Version = "development"
    10  
    11  func init() {
    12  	// Version is set by ldflags on build.
    13  	if Version != "development" {
    14  		return
    15  	}
    16  
    17  	info, ok := debug.ReadBuildInfo()
    18  	if !ok {
    19  		return
    20  	}
    21  
    22  	// https://github.com/golang/go/issues/29228
    23  	if info.Main.Version == "(devel)" || info.Main.Version == "" {
    24  		return
    25  	}
    26  
    27  	Version += "-" + info.Main.Version
    28  }