package version

import (
	"fmt"
	"runtime"
)

var (
	semVersion   = "v0.0.0"
	gitVersion   = "v0.0.0"
	gitCommit    = ""
	gitTreeState = ""
)

func Get() Info {
	return Info{
		SemVersion:   semVersion,
		GitVersion:   gitVersion,
		GitCommit:    gitCommit,
		GitTreeState: gitTreeState,
		GoVersion:    runtime.Version(),
		Compiler:     runtime.Compiler,
		Platform:     fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
	}
}

// Info defines version info
type Info struct {
	SemVersion   string `json:"semVersion"`
	GitVersion   string `json:"gitVersion"`
	GitCommit    string `json:"gitCommit"`
	GitTreeState string `json:"gitTreeState"`
	GoVersion    string `json:"goVersion"`
	Compiler     string `json:"compiler"`
	Platform     string `json:"platform"`
}

// String returns version info
func (info Info) String() string {
	return info.SemVersion
}
