Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix named string issue #30

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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