Feedback on avoiding duplicate text lookup values at compile time

In case anyone is interested in this - I haven’t used Stringer since it doesn’t fit my use case well. Instead I have gone down a different (painful) route of using reflect on a struct, so I now have a struct that defines the (unique) fields including some struct tags that I use as well, e.g.

type EveryDefn struct {
	TypeName struct{}                `_:"system.every"`
	Class    struct{}                `_:"misc"`
	_        text.Text               `txt:"Every " iconify:"true"`
	Secs     numberinput.NumberInput `empty:"seconds" min:"0" max:"999" width:"4" default:"1"`
	_        text.Text               `txt:"seconds"`
	Callback idinput.IdInput
}

This defines the unique field names (and also allows struct tags that I need). The disadvantage is that this may error on running rather than on go generate. The benefit is not having to run go generate.

In my case, I run this:

	every := &EveryDefn{}
	...New(every)

This creates a struct instance and then initializes the instance by reflecting through the fields accessing the struct tags, e.g. setting Secs.Empty = “seconds” and Secs.Min = 0 (int).

But as I said - specific to my use case :slight_smile: