A small package used to identify the OS and Architecture of a binary from a few bytes of a file, made as a support package for github.com/earentir/gitearelease
import (
"fmt""github.com/earentir/identifybin"
)
funccheckVersion() {
// Get OS of attachment binaryurl:="https://github.com/earentir/subscan/releases/download/v0.1.5/subscan"byteCount:=int64(256) // number of bytes to downloadbytes, err:=identifybin.DownloadFirstNBytes(url, byteCount)
iferr!=nil {
fmt.Println("Error:", err)
break
}
binType, err:=identifybin.DetectOSAndArch(bytes)
iferr!=nil {
fmt.Println("Error:", err)
break
}
fmt.Printf("%s %s %s\n", binType.OperatingSystem, binType.Arch, binType.Endianess)
}funcDetectOSAndArch(inputinterface{}) (BinaryType, error)| Parameter | Type | Description |
|---|---|---|
input | string or []byte | Required |
DetectOSAndArch will either take a byte array or a string and then detect the OS and Architecture of that file
funcDownloadFirstNBytes(urlstring, byteCountint64) ([]byte, error)| Parameter | Type | Description |
|---|---|---|
url | string | Required |
byteCount | int64 | Required |
DownloadFirstNBytes downloads the first N bytes of a file from a URL.
I will always follow the Linux Kernel License as primary, if you require any other OPEN license please let me know and I will try to accomodate it.