-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use condition build for os vendor syscall
- Loading branch information
1 parent
4d5a859
commit d5cc32b
Showing
3 changed files
with
55 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//go:build !linux | ||
// +build !linux | ||
|
||
package updateutils | ||
|
||
import ( | ||
"encoding/base64" | ||
"runtime" | ||
"strings" | ||
) | ||
|
||
// Get OS Vendor returns the linux distribution vendor | ||
// if not linux then returns runtime.GOOS | ||
func GetOSVendor() string { | ||
return runtime.GOOS | ||
} | ||
|
||
// returns platform metadata | ||
func getPlatformMetadata() string { | ||
tmp := runtime.GOOS + "|" + runtime.GOARCH | ||
return strings.TrimSuffix(base64.StdEncoding.EncodeToString([]byte(tmp)), "==") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package updateutils | ||
|
||
import ( | ||
"encoding/base64" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/zcalusic/sysinfo" | ||
) | ||
|
||
// Get OS Vendor returns the linux distribution vendor | ||
// if not linux then returns runtime.GOOS | ||
func GetOSVendor() string { | ||
var si sysinfo.SysInfo | ||
si.GetSysInfo() | ||
return si.OS.Vendor | ||
} | ||
|
||
// returns platform metadata | ||
func getPlatformMetadata() string { | ||
var si sysinfo.SysInfo | ||
si.GetSysInfo() | ||
tmp := strings.ReplaceAll(si.Board.Vendor, " ", "_") + "|" + strings.ReplaceAll(si.Board.Name, " ", "_") | ||
if tmp == "|" { | ||
// instead of just empty string return os for more context | ||
tmp = runtime.GOOS + "|" + runtime.GOARCH | ||
} | ||
return strings.TrimSuffix(base64.StdEncoding.EncodeToString([]byte(tmp)), "==") | ||
} |