github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/version/version.go (about)

     1  // Copyright © 2021 Alibaba Group Holding Ltd.
     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  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package version
    16  
    17  import (
    18  	"fmt"
    19  	"runtime"
    20  )
    21  
    22  // Get returns the overall codebase version. It's for detecting
    23  // what code a binary was built from.
    24  func Get() Info {
    25  	// These variables typically come from -ldflags settings and in
    26  	// their absence fallback to the settings in ./base.go
    27  	return Info{
    28  		Major:      gitMajor,
    29  		Minor:      gitMinor,
    30  		GitVersion: gitVersion,
    31  		GitCommit:  gitCommit,
    32  		BuildDate:  buildDate,
    33  		GoVersion:  runtime.Version(),
    34  		Compiler:   runtime.Compiler,
    35  		Platform:   fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
    36  	}
    37  }