Gob encoding for below structure does not work :
type A struct {
sync.RWMutex
ID int
Value string
}
because sync.RWMutex does not have any exported field.
If I do:
type A struct {
lock sync.RWMutex
ID int
Value string
}
now it works, as lock is a private field.
But then I have to do A.lock.Lock(), which doesn't sound very correct.
Other approach can be :
type B struct {
A
sync.RWMutex
}
Can you please tell me if there is a better approach to this? As both look
difficult to justify, unless you know its due to requirement of gob
encoding.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.