Categorygithub.com/peczenyj/go-protected
repositorypackage
0.2.0
Repository: https://github.com/peczenyj/go-protected.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

go-protected

tag Go Version GoDoc Go Lint codecov Report card CodeQL Dependency Review License Latest release GitHub Release Date Last commit PRs Welcome

yet another mutex-protected variable in golang

usage

    lockVar := goprotected.New(new(int)) // import "github.com/peczenyj/go-protected"

    lockVar.Use(func(i *int) {
        *i++
    })

    lockVar.Use(func(i *int) {
        fmt.Println("got i=", *i)
    })

    // Output:
    // got i= 1