...

Source file src/github.com/chaos-mesh/chaos-mesh/pkg/version/version.go

Documentation: github.com/chaos-mesh/chaos-mesh/pkg/version

     1  // Copyright 2019 Chaos Mesh Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package version
    15  
    16  import (
    17  	"fmt"
    18  	"runtime"
    19  )
    20  
    21  var (
    22  	gitVersion = "v0.0.0-master+$Format:%h$"
    23  	gitCommit  = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD)
    24  
    25  	buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
    26  )
    27  
    28  // PrintVersionInfo show version info to Stdout
    29  func PrintVersionInfo(name string) {
    30  	fmt.Printf("%s Version: %#v\n", name, Get())
    31  }
    32  
    33  // Get returns the overall codebase version. It's for detecting
    34  // what code a binary was built from.
    35  func Get() Info {
    36  	// These variables typically come from -ldflags settings
    37  	return Info{
    38  		GitVersion: gitVersion,
    39  		GitCommit:  gitCommit,
    40  		BuildDate:  buildDate,
    41  		GoVersion:  runtime.Version(),
    42  		Compiler:   runtime.Compiler,
    43  		Platform:   fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
    44  	}
    45  }
    46