1
0
mirror of https://github.com/taigrr/go-selfupdate synced 2025-01-18 04:33:12 -08:00

Add setting platform by GOOS and GOARCH env vars

This commit is contained in:
Thomas Frössman 2015-01-08 09:53:18 +01:00
parent 1f1bb201ba
commit ab4f862aaa

13
main.go
View File

@ -137,8 +137,17 @@ func createBuildDir() {
func main() {
outputDirFlag := flag.String("o", "public", "Output directory for writing updates")
platformFlag := flag.String("platform", runtime.GOOS+"-"+runtime.GOARCH,
"Target platform in the form OS-ARCH. Defaults to running os/arch.")
var defaultPlatform string
goos := os.Getenv("GOOS")
goarch := os.Getenv("GOARCH")
if goos != "" && goarch != "" {
defaultPlatform = goos + "-" + goarch
} else {
defaultPlatform = runtime.GOOS + "-" + runtime.GOARCH
}
platformFlag := flag.String("platform", defaultPlatform,
"Target platform in the form OS-ARCH. Defaults to running os/arch or the combination of the environment variables GOOS and GOARCH if both are set.")
flag.Parse()
if flag.NArg() < 2 {