Closed trim21 closed 4 weeks ago
Hey, to better understand - how are you running into this issue/what's your use case?
Hey, to better understand - how are you running into this issue/what's your use case?
i have a config file will be used in multiple goroutine, I don't want to write a duplicate thread safe structure
type Config struct {
Opt atomic.Pointer[string] `json:"opt"`
}
config.Opt
may be write and read concurrently, and initial parsed from config, maybe nil.
Currently I need to do it this way:
type Config struct {
Opt *string `json:"opt"`
}
type safeConfig struct {
Opt atomic.Pointer[string]
}
many atomic value support
MarshalJSON
andUnmarshalJSON
, any plan forPointer[T]
?