github.com/tomsquest/goreleaser@v0.34.3-0.20171008022654-7d6ef4d338b3/internal/buildtarget/buildtarget.go (about)

     1  package buildtarget
     2  
     3  import (
     4  	"fmt"
     5  	"runtime"
     6  )
     7  
     8  // Runtime is the current runtime buildTarget
     9  var Runtime = Target{runtime.GOOS, runtime.GOARCH, ""}
    10  
    11  // New builtarget
    12  func New(goos, goarch, goarm string) Target {
    13  	return Target{goos, goarch, goarm}
    14  }
    15  
    16  // Target is a build target
    17  type Target struct {
    18  	OS, Arch, Arm string
    19  }
    20  
    21  // Env returns the current Target as environment variables
    22  func (t Target) Env() []string {
    23  	return []string{
    24  		"GOOS=" + t.OS,
    25  		"GOARCH=" + t.Arch,
    26  		"GOARM=" + t.Arm,
    27  	}
    28  }
    29  
    30  func (t Target) String() string {
    31  	return fmt.Sprintf("%v%v%v", t.OS, t.Arch, t.Arm)
    32  }
    33  
    34  // PrettyString is a prettier version of the String method.
    35  func (t Target) PrettyString() string {
    36  	return fmt.Sprintf("%v/%v%v", t.OS, t.Arch, t.Arm)
    37  }