Hi,
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.