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

go-selfupdate binary uses os env to detect arch/platform so you can crosscompile

This commit is contained in:
Mark Sanborn 2013-11-15 12:34:34 -08:00
parent f1263af1c0
commit 74aa055b82

22
main.go
View File

@ -1,23 +1,21 @@
package main package main
import ( import (
"fmt"
"os"
"encoding/json"
"io/ioutil"
"io"
"path/filepath"
"compress/gzip"
"bytes" "bytes"
"compress/gzip"
"crypto/sha256" "crypto/sha256"
"encoding/json"
"fmt"
"github.com/kr/binarydist" "github.com/kr/binarydist"
"runtime" "io"
"io/ioutil"
"os"
"path/filepath"
//"runtime"
//"encoding/base64" //"encoding/base64"
) )
const ( var plat string
plat = runtime.GOOS + "-" + runtime.GOARCH
)
type current struct { type current struct {
Version string Version string
@ -61,6 +59,8 @@ func newGzReader(r io.ReadCloser) io.ReadCloser {
} }
func main() { func main() {
plat = os.Getenv("GOOS") + "-" + os.Getenv("GOARCH")
appPath := os.Args[1] appPath := os.Args[1]
version := os.Args[2] version := os.Args[2]
genDir := "public" genDir := "public"