diff --git a/field_generator.go b/field_generator.go index 1d9ff0c..687ac99 100644 --- a/field_generator.go +++ b/field_generator.go @@ -132,6 +132,9 @@ func (g *fieldGenerator) writePointerDef(ctx fieldGenContext) { case astparser.TypeSimple: g.writeSimpleDef(ctx.withFieldName("*"+ctx.fieldName)) case astparser.TypeCustom: + if tt.AliasType != nil { + ctx = ctx.withFieldName("*"+ctx.fieldName) + } g.writeCustomDef(ctx) default: panic(fmt.Sprintf("unsupported array pointer innter type %T field name %s", tt, ctx.fieldName)) diff --git a/fixtures_test/custom.go b/fixtures_test/custom.go index 87665fd..b73689c 100644 --- a/fixtures_test/custom.go +++ b/fixtures_test/custom.go @@ -43,6 +43,7 @@ type Dep struct { ConstInt ConstInt ConstStrArray []ConstStr ConstStrMap map[string]ConstStr + ConstStrPtr *ConstStr } type Optional struct { diff --git a/fixtures_test/custom.zap.go b/fixtures_test/custom.zap.go index d3b66e6..18f5fd0 100644 --- a/fixtures_test/custom.zap.go +++ b/fixtures_test/custom.zap.go @@ -152,6 +152,10 @@ func (m *Dep) MarshalLogObject(enc zapcore.ObjectEncoder) error { return nil })) + keyName = "ConstStrPtr" + if m.ConstStrPtr != nil { + enc.AddString(keyName, string(*m.ConstStrPtr)) + } return nil } diff --git a/generator_test.go b/generator_test.go index 69e2d72..b9011f6 100644 --- a/generator_test.go +++ b/generator_test.go @@ -22,7 +22,7 @@ var _ = Describe("backoff", func() { It("should generate golden files", func() { cfg := astparser.Config{ InputDir: "fixtures_test", - IncludeRegexp: "primitives.go|custom.go", + IncludeRegexp: "custom.go", } sources, err := astparser.Load(cfg) Ω(err).ShouldNot(HaveOccurred())