You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
package errorx
|
|
|
|
import "sync/atomic"
|
|
|
|
type AtomicError struct {
|
|
err atomic.Value // error
|
|
}
|
|
|
|
func (ae *AtomicError) Set(err error) {
|
|
ae.err.Store(err)
|
|
}
|
|
|
|
func (ae *AtomicError) Load() error {
|
|
if v := ae.err.Load(); v != nil {
|
|
return v.(error)
|
|
}
|
|
return nil
|
|
}
|