Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
uname-it: add OSUname + ArchUname from some Googling
Browse files Browse the repository at this point in the history
  • Loading branch information
fenollp committed Dec 31, 2017
1 parent b48e090 commit 176bea3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
16 changes: 10 additions & 6 deletions go.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -58,9 +60,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
Expand Down
27 changes: 27 additions & 0 deletions platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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 (
OsList = []string{
"darwin",
Expand Down

0 comments on commit 176bea3

Please sign in to comment.