Skip to content

Commit

Permalink
Merge pull request keystone-engine#236 from zchee/go/sample
Browse files Browse the repository at this point in the history
go: Update to latest keystone package API & Remove unnecessary else
  • Loading branch information
aquynh authored Aug 9, 2016
2 parents f8a3eba + 5e01dd0 commit 99b4ce9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions bindings/go/keystone/samples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 comments on commit 99b4ce9

Please sign in to comment.