Skip to content

Allow non-exported fields with reform tag #169

@AlekSi

Description

@AlekSi

Consider the following code:

package audit

type Message struct {
	ID      string `reform:"id,pk"`
	Method  string `reform:"method"`
	Payload interface{}
	body    []byte `reform:"body"`
}

func (m *Message) BeforeInsert() error {
	b, err := json.Marshal(m.Payload)
	m.body = b
	return err
}

An external user of that package can set Payload, but it is always stored in serialized form.

Currently, it is not possible due to check in reform tool: Message has non-exported field body with "reform:" tag, it is not allowed. But we don't have a reason for that check anymore – generated code can access this field directly, no reflection (which almost always works only for exported fields) is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions