-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ce9cc1
commit 7084459
Showing
26 changed files
with
286 additions
and
469 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
File renamed without changes.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,45 +1,37 @@ | ||
# Detailed Platform Detection at Runtime | ||
[![GoDoc](https://godoc.org/github.com/codemodify/SystemKit?status.svg)](https://godoc.org/github.com/codemodify/systemkit-platform) | ||
[![0-License](https://img.shields.io/badge/license-0--license-brightgreen)](https://github.com/codemodify/TheFreeLicense) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/codemodify/SystemKit)](https://goreportcard.com/report/github.com/codemodify/SystemKit) | ||
[![Test Status](https://github.com/danawoodman/systemservice/workflows/Test/badge.svg)](https://github.com/danawoodman/systemservice/actions) | ||
![code size](https://img.shields.io/github/languages/code-size/codemodify/SystemKit?style=flat-square) | ||
# Detailed CPU Detection at Runtime | ||
|
||
# Usages | ||
- Intented use is as a library in Go code | ||
# Usage | ||
- as a library in Go code | ||
```go | ||
package main | ||
|
||
import platform "github.com/codemodify/systemkit-platform" | ||
import platformCPU "github.com/codemodify/systemkit-platform-cpu" | ||
|
||
func main() { | ||
cpuInfo := platformCPU.Info() | ||
|
||
// Example 1 | ||
fmt.Println(platform.GetInfo().CPU.Architecture) // => ex: arm OR amd64 | ||
fmt.Println(platform.GetInfo().CPU.Variant.Name) // => ex: armv5 OR armv6 OR armv8, etc | ||
fmt.Println(platform.GetInfo().CPU.Variant.Detailed) // => ex: armv5te | ||
fmt.Println(cpuInfo.Architecture) // => ex: arm OR amd64 | ||
fmt.Println(cpuInfo.Variant.Name) // => ex: armv5 OR armv6 OR armv8, etc | ||
fmt.Println(cpuInfo.Variant.Detailed) // => ex: armv5te | ||
|
||
// Example 2 | ||
if platform.IsArm(platform.GetInfo().CPU.Architecture) { | ||
if if platform.GetInfo().CPU.Variant.Name == platform.CPUV_ARMv8 { | ||
if platformCPU.IsArm(cpuInfo.Architecture) { | ||
if cpuInfo.Variant.Name == platformCPU.CPUV_ARMv8 { | ||
// we got AMRv8 | ||
} else if platform.GetInfo().CPU.Variant.Name == platform.CPUV_ARMv5 { | ||
if platform.GetInfo().CPU.Variant.Detailed == platform.CPUVD_ARMv5T { | ||
} else if cpuInfo.Variant.Name == platformCPU.CPUV_ARMv5 { | ||
if cpuInfo.Variant.Detailed == platformCPU.CPUVD_ARMv5T { | ||
// we got ARMv5t | ||
} else if platform.GetInfo().CPU.Variant.Detailed == platform.CPUVD_ARMv5TE { | ||
} else if cpuInfo.Variant.Detailed == platformCPU.CPUVD_ARMv5TE { | ||
// we got ARMv5te | ||
} else if platform.GetInfo().CPU.Variant.Detailed == platform.CPUVD_ARMv5TEJ { | ||
} else if cpuInfo.Variant.Detailed == platformCPU.CPUVD_ARMv5TEJ { | ||
// we got ARMv5tej | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
- | ||
|
||
# References | ||
- `go tool dist list` | ||
- https://github.com/golang/go/blob/master/src/go/build/syslist.go | ||
- https://github.com/containerd/containerd | ||
- https://github.com/mackerelio/go-osstat/blob/master/cpu/cpu_linux.go | ||
- as a binary on a a bunch of platforms | ||
- `https://github.com/codemodify/systemkit-platform-cpu/releases/latest` | ||
![](https://raw.githubusercontent.com/codemodify/systemkit-platform-cpu/master/.helper-files/dox/sample.png) |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.