Skip to content

Checks that access to shared resources is protected

License

Notifications You must be signed in to change notification settings

mneverov/protectedby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Checks that access to shared resources is protected

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages