May or may not be of interest, but I experimented with an alternative
approach in
https://github.com/myitcv/x/blob/master/immutable/_doc/immutableGen.md
Although this is where the term "immutable" gets massively overloaded,
because the result of immutableGen is (as I understand it) persistent
data structures. My use of the term "immutable" is more a nod to
https://github.com/immutable-js/immutable-js which inspired the
pattern.
That caveat aside.
It's a code generation approach whereby you declare immutable templates, e.g.
type _Imm_Banana struct {
Name string
age int
}
You then get code generated get/set methods that respect the
exported-ness of the template fields.
immutableVet can then be used to verify correct use of struct fields
within a package, i.e. that you don't have any non-generated code that
subverts the get/set methods.
You can also have "immutable" maps and slices.
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
golang-nuts...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/7ee35405-fef4-415b-ae5d-95322b4065aa%40googlegroups.com.