permcheck
is a Golang package that provides a convenient way to check and manage permissions. It allows permissions to be combined using boolean logic (AND, OR), making it a flexible tool for implementing authorization systems.
- Simple to use: Easily define and check permissions.
- Logical operators: Combine permissions with AND and OR operations.
- Customizable: Define your own permission types.
To install permcheck, use go get
:
go get github.com/thefabric-io/permcheck
package main
import (
"errors"
"fmt"
"github.com/thefabric-io/permcheck"
)
func main() {
// Create new permissions
p1 := permcheck.New("read", errors.New("read access required"))
p2 := permcheck.New("write", errors.New("write access required"))
// Create a combined permission
p3 := permcheck.And(p1, p2)
// Check permissions
err := p3.Satisfies([]string{"read", "write"})
if err != nil {
fmt.Println(err)
}
}
Contributions to permcheck
are welcome! Please see CONTRIBUTING.md for details on how to contribute.
This project is licensed under the MIT License - see the LICENSE.md file for details.
We hope this library proves to be a valuable tool in your software development toolkit.