Atomic operations as methods on types
Note: As of Go 1.19 the standard library package sync/atomic
implements similar data types, so this package here will not see further
development. It will stay archived.
package main
import (
"fmt"
"github.com/nightlyone/atomic"
)
type Service struct {
Health atomic.Bool
}
func main() {
service := new(Service)
isHealthy := service.Health.Value()
fmt.Printf("service is healthy? %t\n", isHealthy)
// Output: service is healthy? false
}BSD-3-Clause