protectedby

command module
v0.0.0-...-10ad165 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 2 Imported by: 0

README

protectedby

Checks that access to shared resources is protected.

go install github.com/mneverov/protectedby@latest

When a shared resource (field) has a comment with protected by <lock_name>, access to this field will be validated to ensure it is guarded by the specified lock.

See code snippet:


type someStruct struct {
    // i is protected by mu. 
    i int
    mu sync.Mutex
}

func foo() {
    s := someStruct{}
    s.i = 42 // not protected access to shared field i, use s.mu.Lock()
}

For more info see tests.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL