Skip to content

Commit

Permalink
codecgen: handle struct fields of type *time.Time correctly
Browse files Browse the repository at this point in the history
Fixes #240
  • Loading branch information
ugorji committed Apr 7, 2018
1 parent 6a0f936 commit b4c50a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions codec/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ func (x *genRunner) selfer(encode bool) {
if encode {
x.line(") CodecEncodeSelf(e *" + x.cpfx + "Encoder) {")
x.genRequiredMethodVars(true)
// x.enc(genTopLevelVarName, t)
x.encVar(genTopLevelVarName, t)
} else {
x.line(") CodecDecodeSelf(d *" + x.cpfx + "Decoder) {")
Expand Down Expand Up @@ -649,7 +648,7 @@ func (x *genRunner) encVar(varname string, t reflect.Type) {
case reflect.Ptr:
telem := t.Elem()
tek := telem.Kind()
if tek == reflect.Array || (tek == reflect.Struct && t != timeTyp) {
if tek == reflect.Array || (tek == reflect.Struct && telem != timeTyp) {
x.enc(varname, genNonPtr(t))
break
}
Expand Down
1 change: 1 addition & 0 deletions codec/values_flex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type AnonInTestStrucIntf struct {
Ms map[string]interface{}
Nintf interface{} //don't set this, so we can test for nil
T time.Time
Tptr *time.Time
}

var testWRepeated512 wrapBytes
Expand Down

0 comments on commit b4c50a2

Please sign in to comment.