Idiomatic way of converting Golang complex structs to Terraform storage format

I’m currently working on improving Terraform provider for my project ( and I struggle to find a good pattern for converting my projects structs into Terraform scheme, so I can store it and present user a nice diff if some condition changes. I’ve tried looking into other providers source, but I couldn’t find any good examples of how to do that.

It would be great to be able to use Go struct tags or something to handle that, so I could avoid so much of the boilerplate code.

Could you point me to some examples/libraries/helpers, which can simplify such process?

At the moment, all HashiCorp-maintained providers do this by hand. We do not have official tooling that supports using struct tags to turn structs into schema, or modeling schema as a struct at all. This is something I’m vaguely interested in, but there are some complications to that that make it harder than it appears at first blush. For example, defining validation functions on attributes is tricky if they’re just properties on a struct.