Is it possible to define an immutable struct in Golang? Once initialized then only read operation on struct\'s field, no modification of field values. If so, how to do that.
There is no way to mark fields/variables as read only in a generic way. The only thing you could do is marking fields/variable as unexported (first letter small) and provide public getters to prevent other packages editing variables.