Skip to content
Snippets Groups Projects
Commit 99b4ce91 authored by Nguyen Anh Quynh's avatar Nguyen Anh Quynh Committed by GitHub
Browse files

Merge pull request #236 from zchee/go/sample

go: Update to latest keystone package API & Remove unnecessary else
parents f8a3eba0 5e01dd06
No related merge requests found
......@@ -8,25 +8,25 @@ import (
"fmt"
"os"
keystone "github.com/keystone-engine/beta/bindings/go/keystone"
"github.com/keystone-engine/keystone/bindings/go/keystone"
)
func main() {
assembly := os.Args[1]
if ks, err := keystone.New(keystone.ArchitectureX86, keystone.Mode32); err != nil {
ks, err := keystone.New(keystone.ARCH_X86, keystone.MODE_32)
if err != nil {
panic(err)
} else {
defer ks.Close()
}
defer ks.Close()
if err := ks.Option(keystone.OptionSyntax, keystone.OptionSyntaxIntel); err != nil {
panic(fmt.Errorf("Could not set syntax option to intel"))
}
if err := ks.Option(keystone.OPT_SYNTAX, keystone.OPT_SYNTAX_INTEL); err != nil {
panic(fmt.Errorf("Could not set syntax option to intel"))
}
if insn, _, ok := ks.Assemble(assembly, 0); !ok {
panic(fmt.Errorf("Could not assemble instruction"))
} else {
fmt.Printf("%s: [%x]", assembly, insn)
}
if insn, _, ok := ks.Assemble(assembly, 0); !ok {
panic(fmt.Errorf("Could not assemble instruction"))
} else {
fmt.Printf("%s: [%x]", assembly, insn)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment