From b07f203bee55f81a0cb6705a68d8434cb33e4cc3 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Sun, 31 Dec 2017 18:43:52 +0100 Subject: [PATCH 1/3] uname-it: add OSUname + ArchUname from some Googling --- go.go | 16 ++++++++++------ platform.go | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/go.go b/go.go index 37edb36..3f40584 100644 --- a/go.go +++ b/go.go @@ -15,9 +15,11 @@ import ( ) type OutputTemplateData struct { - Dir string - OS string - Arch string + Dir string + OS string + OSUname string + Arch string + ArchUname string } type CompileOpts struct { @@ -59,9 +61,11 @@ func GoCrossCompile(opts *CompileOpts) error { return err } tplData := OutputTemplateData{ - Dir: filepath.Base(opts.PackagePath), - OS: opts.Platform.OS, - Arch: opts.Platform.Arch, + Dir: filepath.Base(opts.PackagePath), + OS: opts.Platform.OS, + OSUname: opts.Platform.OSUname(), + Arch: opts.Platform.Arch, + ArchUname: opts.Platform.ArchUname(), } if err := tpl.Execute(&outputPath, &tplData); err != nil { return err diff --git a/platform.go b/platform.go index 88428bc..8a9c704 100644 --- a/platform.go +++ b/platform.go @@ -25,6 +25,33 @@ func (p *Platform) String() string { return fmt.Sprintf("%s/%s", p.OS, p.Arch) } +/// Like `uname -s` +func (p *Platform) OSUname() string { + return map[string]string{ + "darwin": "Darwin", + "dragonfly": "DragonFly", + "freebsd": "FreeBSD", + "linux": "Linux", + "netbsd": "NetBSD", + "openbsd": "OpenBSD", + "plan9": "Plan9", + "solaris": "SunOS", + "windows": "Windows", + }[p.OS] +} + +/// Like `uname -m` +func (p *Platform) ArchUname() string { + return map[string]string{ + "386": "i386", + "amd64": "x86_64", + "arm": "arm", + "arm64": "aarch64", + "ppc64": "ppc64", + "ppc64le": "ppc64le", + }[p.Arch] +} + var ( Platforms_1_0 = []Platform{ {"darwin", "386", true}, From 7b7a737ee379c2f5a8ce1d95f3171a4826bf2765 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Sun, 31 Dec 2017 18:46:05 +0100 Subject: [PATCH 2/3] uname-it: some documentation --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index d8098c9..dee98b1 100644 --- a/main.go +++ b/main.go @@ -200,8 +200,9 @@ Output path template: The output path for the compiled binaries is specified with the "-output" flag. The value is a string that is a Go text template. - The default value is "{{.Dir}}_{{.OS}}_{{.Arch}}". The variables and - their values should be self-explanatory. + The default value is "{{.Dir}}_{{.OS}}_{{.Arch}}". Other available + variables are OSUname and ArchUname which should correspond to uname -s + and uname -m respectively. Platforms (OS/Arch): From 8f9d0bdfdd0371d0d118d1e43d135f04391ba6fa Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Tue, 23 Jan 2018 18:24:44 +0100 Subject: [PATCH 3/3] uname-it: found the link to find add the blanks --- platform.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/platform.go b/platform.go index 8a9c704..5a1270f 100644 --- a/platform.go +++ b/platform.go @@ -26,29 +26,47 @@ func (p *Platform) String() string { } /// Like `uname -s` +// Matches https://github.com/golang/go/blob/master/src/go/build/syslist.go func (p *Platform) OSUname() string { return map[string]string{ + //"android": "darwin": "Darwin", "dragonfly": "DragonFly", "freebsd": "FreeBSD", "linux": "Linux", + //"nacl": "netbsd": "NetBSD", "openbsd": "OpenBSD", "plan9": "Plan9", "solaris": "SunOS", "windows": "Windows", + //"zos": }[p.OS] } /// Like `uname -m` +// Matches https://github.com/golang/go/blob/master/src/go/build/syslist.go func (p *Platform) ArchUname() string { return map[string]string{ "386": "i386", "amd64": "x86_64", + //"amd64p32": "arm": "arm", + //"armbe": "arm64": "aarch64", + //"arm64be": "ppc64": "ppc64", "ppc64le": "ppc64le", + //"mips": + //"mipsle": + //"mips64": + //"mips64p32": + //"mips64p32le": + //"ppc": + //"s390": + //"s390x": + //"sparc": + //"sparc64": }[p.Arch] }