Skip to content

Commit

Permalink
Correct decode 80%
Browse files Browse the repository at this point in the history
  • Loading branch information
2tvenom committed Mar 15, 2014
1 parent 5c8dc64 commit cf2cee2
Show file tree
Hide file tree
Showing 2 changed files with 370 additions and 90 deletions.
18 changes: 16 additions & 2 deletions src/cbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,30 @@ type Vector struct {
}

func main() {
v := Vector{1,2,3}
var v float32

v = 12.3

var buffTest bytes.Buffer
encoder := cbor.NewEncoder(&buffTest)
ok, error := encoder.Encode(v)
ok, error := encoder.Marshal(v)

if !ok {
fmt.Errorf("Error decoding %s", error)
} else {
fmt.Printf("Variable Hex = % x\n", buffTest.Bytes())
fmt.Printf("Variable = %v\n", buffTest.Bytes())
}
fmt.Printf("-----------------\n")

var vd float32

ok, err := encoder.Unmarshal(buffTest.Bytes(), &vd)

if !ok {
fmt.Printf("Error Unmarshal %s", err)
return
}

fmt.Printf("%v", vd)
}
Loading

0 comments on commit cf2cee2

Please sign in to comment.