I would like to develop a library in Go which makes use of the different file formats of the debug package in the go standard packages (http://golang.org/pkg/debug/). The idea is to open a file and print out information about that file. Now I would like to automatically recognize the correct file format by testing all relevant file types. For instance, to test if a file is a simple Mach-O or a fat Mach-O file, I am trying to open the file with both Open methods:
file, err := macho.Open(filename)
if err != nil {
fmt.Println("Not an Mach-O file.")
}
file, err = macho.OpenFat(filename)
if err != nil {
fmt.Println("Not an fat Mach-O file. Exiting.")
return
}
Unfortunately the file variable is (of course) type checked, and I get the following error:
cannot assign *macho.FatFile to file (type *macho.File) in multiple assignment
I am not even sure of this is the correct way of approaching this. Can anyone point me to the right direction how to perfom this properly?