1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
2017-12-18 09:19:02 -02:00

39 lines
805 B
Go

package buildtarget
import (
"fmt"
"runtime"
)
// Runtime is the current runtime buildTarget
var Runtime = Target{runtime.GOOS, runtime.GOARCH, ""}
// New builtarget
func New(goos, goarch, goarm string) Target {
return Target{goos, goarch, goarm}
}
// Target is a build target
type Target struct {
OS, Arch, Arm string
}
// Env returns the current Target as environment variables
func (t Target) Env() []string {
return []string{
"GOOS=" + t.OS,
"GOARCH=" + t.Arch,
"GOARM=" + t.Arm,
}
}
func (t Target) String() string {
// TODO: maybe replace this as suggested to OS_ArchArm?
return fmt.Sprintf("%v%v%v", t.OS, t.Arch, t.Arm)
}
// PrettyString is a prettier version of the String method.
func (t Target) PrettyString() string {
return fmt.Sprintf("%v/%v%v", t.OS, t.Arch, t.Arm)
}