https://github.com/remoteit/systemkit-platform-os
https://github.com/remoteit/systemkit-platform-os
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/remoteit/systemkit-platform-os
- Owner: remoteit
- License: other
- Fork: true (codemodify/systemkit-platform-os)
- Created: 2020-10-15T04:55:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-14T02:15:37.000Z (over 4 years ago)
- Last Synced: 2024-06-20T10:19:02.505Z (about 2 years ago)
- Language: Shell
- Size: 604 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
#  Detailed OS Detection at Runtime
[](https://github.com/codemodify/systemkit-platform-os/releases/latest)


[](https://github.com/codemodify/TheFreeLicense)


[](https://goreportcard.com/report/github.com/codemodify/systemkit-platform-os)
[](https://godoc.org/github.com/codemodify/systemkit-platform-os)






#  Usage
- as a library in Go code
```go
package main
import (
"encoding/json"
"fmt"
"os"
platformOS "github.com/codemodify/systemkit-platform-os"
)
func main() {
data, err := json.Marshal(platformOS.Info())
if err != nil {
fmt.Println(err.Error())
}
if len(os.Args) > 1 && os.Args[1] == "-p" {
data, err = json.MarshalIndent(platformOS.Info(), "", " ")
if err != nil {
fmt.Println(err.Error())
}
}
if
fmt.Println(string(data))
if osInfo.Name == platformOS.OS_Linux {
fmt.Println("WE ARE ON Linux")
fmt.Println("Distro: ", osInfo.Distribution)
} else if platformOS.IsBSD(osInfo.Name) {
fmt.Println("WE ARE ON BSD family")
} else if platformOS.IsDarwin(osInfo.Name) {
fmt.Println("WE ARE ON WINDOWS family")
} else if platformOS.IsWindows(osInfo.Name) {
fmt.Println("WE ARE ON WINDOWS family")
}
}
```
- as a binary on a a bunch of platforms
- `https://github.com/codemodify/systemkit-platform-os/releases/latest`
