I have a go program in which I want to embed a binary for execute later. But since I need my program to be cross platform with the same codebase, I have two binaries (one for linux and one for windows).
I don't want to load both in memory, so I'm trying to embed only one of them, based on the value of runtime.GOOS
.
The following code is non-sense but it will help you understand what I need.
runtimeOs := runtime.GOOS
if runtimeOs == "windows" {
//go:embed vol.exe
var volatilityWindows []byte
} else if runtimeOs == "linux" {
//go:embed vol
var volatilityLinux []byte
} else {
fmt.Println("Unsupported operating system:", runtimeOs)
os.Exit(1)
}