-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Thomas Fossati <[email protected]>
- Loading branch information
1 parent
2370afa
commit 5e7e827
Showing
18 changed files
with
1,449 additions
and
802 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cmw | ||
|
||
import ( | ||
"reflect" | ||
|
||
"github.com/fxamacker/cbor/v2" | ||
) | ||
|
||
var ( | ||
em, emError = initCBOREncMode() | ||
dm, dmError = initCBORDecMode() | ||
) | ||
|
||
func initCBOREncMode() (en cbor.EncMode, err error) { | ||
o := cbor.CoreDetEncOptions() // use preset options as a starting point | ||
return o.EncMode() | ||
} | ||
|
||
func initCBORDecMode() (en cbor.DecMode, err error) { | ||
tags := cbor.NewTagSet() | ||
tags.Add( | ||
cbor.TagOptions{EncTag: cbor.EncTagNone, DecTag: cbor.DecTagOptional}, | ||
reflect.TypeOf(CMW{}), | ||
765) | ||
|
||
return cbor.DecOptions{}.DecModeWithTags(tags) | ||
} | ||
|
||
func init() { | ||
if emError != nil { | ||
panic(emError) | ||
} | ||
if dmError != nil { | ||
panic(dmError) | ||
} | ||
} |
Oops, something went wrong.