zclconf / go-cty

A type system for dynamic values in Go applications
MIT License
338 stars 70 forks source link

Add support for decoding into structs with a custom tag #148

Open gastrodon opened 1 year ago

gastrodon commented 1 year ago

I'd like a feature for a project that I'm working on to be able to do something like gocty.FromCtyValue, but for a struct with field tags of a kind other than cty:"". Is this within the scope of this project / compatible with design goals?

I've taken a stab at it here - that branch updates func structTagIndices to take a tag string instead of always using cty, and adds a new function func FromCtyValueTagged that takes a new parameter tag string

My project uses this function to decode values into structs that are provided by a plugin and everything seems to work ( +cty tests pass )

gastrodon commented 3 months ago

pr'd #181