github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/cmd/srv-applet-mgr/types/build.go (about)

     1  package types
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/fatih/color"
     8  
     9  	"github.com/machinefi/w3bstream/pkg/depends/base/consts"
    10  )
    11  
    12  var (
    13  	Name      string
    14  	Feature   string
    15  	Version   string
    16  	Timestamp string
    17  	Group     string
    18  
    19  	BuildVersion string
    20  )
    21  
    22  func init() {
    23  	if Name == "" {
    24  		Name = "srv-applet-mgr"
    25  	}
    26  	if Feature == "" {
    27  		Feature = "unknown"
    28  	}
    29  	if Version == "" {
    30  		Version = "unknown"
    31  	}
    32  	if Timestamp == "" {
    33  		Timestamp = "unknown"
    34  	}
    35  	if Group == "" {
    36  		Group = "srv-applet-mgr"
    37  	}
    38  	_ = os.Setenv(consts.EnvProjectName, Name)
    39  	_ = os.Setenv(consts.EnvProjectFeat, Feature)
    40  	_ = os.Setenv(consts.EnvProjectVersion, Version)
    41  	_ = os.Setenv(consts.EnvResourceGroup, Group)
    42  
    43  	BuildVersion = fmt.Sprintf("%s@%s_%s", Feature, Version, Timestamp)
    44  
    45  	fmt.Printf(color.CyanString("%s: %s\n\n", Name, BuildVersion))
    46  }