easyjson icon indicating copy to clipboard operation
easyjson copied to clipboard

[]byte field is incorrectly generated as a string field, making it unmarshalable

Open bqback opened this issue 2 years ago • 0 comments

Tested on this struct

type AvatarChangeInfo struct {
	UserID   uint64 `json:"-" valid:"-"`
	Avatar   []byte `json:"avatar" valid:"-"`
	Filename string `json:"filename" valid:"-"`
	Mimetype string `json:"mimetype" valid:"-"`
}

causing

parse error: expected string near offset 17 of 'avatar'

I'm also having this issue with a different struct with a []byte field.

I've tried generating the easyjson files with the -byte tag -- no effect.

I've tried generating the easyjson files with the nounsafe build tag (with easyjson -all -build_tags "easyjson_nounsafe" file.go, as vaguely described in the docs). which instead makes none of the generated methods be linked to the structs, rendering the easyjson marshaler/unmarshaler unusable entirely.

bqback avatar Dec 19 '23 06:12 bqback