package main import ( "github.com/alecthomas/kong" "ios-wrapper/pkg/ios/macho" "bytes" "fmt" "os" ) type Argument struct { One string `arg short:"o" required help:"" type:"existingfile"` Two string `arg short:"t" required help:"" type:"existingfile"` } func main() { var cli Argument kong.Parse(&cli) compare(cli.One, cli.Two) } func compare(one string, two string) { f1, _ := os.OpenFile(one, os.O_RDONLY, 0644) f2, _ := os.OpenFile(two, os.O_RDONLY, 0644) var mc1 macho.MachoContext var mc2 macho.MachoContext mc1.ParseFile(f1, 0) mc2.ParseFile(f2, 0) s1 := mc1.FindSection("__text") s2 := mc2.FindSection("__text") if s1.Size() == s2.Size() { fmt.Println("Size is equal") } else { fmt.Printf("%x <> %x\n", s1.Size(), s2.Size()) } data1 := mc1.Cut(uint64(s1.Offset()), s1.Size()) data2 := mc1.Cut(uint64(s2.Offset()), s2.Size()) if bytes.Compare(data1, data2) == 0 { fmt.Println("Data is equal") } }