Skip to content

Commit

Permalink
Merge pull request #30 from whyrusleeping/fix/named-string
Browse files Browse the repository at this point in the history
Fix named string issue
  • Loading branch information
Jakub Sztandera committed Jul 23, 2020
2 parents 13e2891 + ad13f0f commit 6a3894a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 27 deletions.
2 changes: 1 addition & 1 deletion gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func emitCborMarshalStringField(w io.Writer, f Field) error {
}
{{ MajorType "w" "cbg.MajTextString" (print "len(" .Name ")") }}
if _, err := io.WriteString(w, {{ .Name }}); err != nil {
if _, err := io.WriteString(w, string({{ .Name }})); err != nil {
return err
}
`)
Expand Down
44 changes: 33 additions & 11 deletions testing/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions testing/cbor_map_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions testing/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import (

const Thingc = 3

type NaturalNumber uint64
type NamedNumber uint64
type NamedString string

type SignedArray struct {
Signed []uint64
}

type SimpleTypeOne struct {
Foo string
Value uint64
Binary []byte
Signed int64
Foo string
Value uint64
Binary []byte
Signed int64
NString NamedString
}

type SimpleTypeTwo struct {
Expand All @@ -25,9 +27,9 @@ type SimpleTypeTwo struct {
SignedOthers []int64
Test [][]byte
Dog string
Numbers []NaturalNumber
Numbers []NamedNumber
Pizza *uint64
PointyPizza *NaturalNumber
PointyPizza *NamedNumber
Arrrrrghay [Thingc]SimpleTypeOne
}

Expand Down

0 comments on commit 6a3894a

Please sign in to comment.