Skip to content

Commit

Permalink
Merge pull request #187 from cloudstruct/docs/utils-package
Browse files Browse the repository at this point in the history
docs: code docs for utils package
  • Loading branch information
agaffney authored Feb 9, 2023
2 parents f949a16 + 7e16e69 commit 0f63e11
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions utils/cbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/fxamacker/cbor/v2"
)

// CborEncode encodes the provided data as CBOR using the correct mode
func CborEncode(data interface{}) ([]byte, error) {
buf := bytes.NewBuffer(nil)
em, err := cbor.CoreDetEncOptions().EncMode()
Expand All @@ -16,6 +17,7 @@ func CborEncode(data interface{}) ([]byte, error) {
return buf.Bytes(), err
}

// CborDecode decodes the provided CBOR into the given destination
func CborDecode(dataBytes []byte, dest interface{}) (int, error) {
data := bytes.NewReader(dataBytes)
dec := cbor.NewDecoder(data)
Expand Down
1 change: 1 addition & 0 deletions utils/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
)

// DumpCborStructure generates an indented string representing an arbitrary data structure for debugging purposes
func DumpCborStructure(data interface{}, prefix string) string {
var ret bytes.Buffer
switch v := data.(type) {
Expand Down
2 changes: 2 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package utils provides random utility functions
package utils

0 comments on commit 0f63e11

Please sign in to comment.