do bitmask better, add (COMPLETELY 100% EXPERIMENTAL NOT DONE YET) eventlog support to logger
This commit is contained in:
45
bitmask/doc.go
Normal file
45
bitmask/doc.go
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Package bitmask handles a flag-like opt/bitmask system.
|
||||
|
||||
See https://yourbasic.org/golang/bitmask-flag-set-clear/ for more information.
|
||||
|
||||
To use this, set constants like thus:
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"r00t2.io/goutils/bitmask"
|
||||
)
|
||||
|
||||
const OPTNONE types.MaskBit = 0
|
||||
const (
|
||||
OPT1 types.MaskBit = 1 << iota
|
||||
OPT2
|
||||
OPT3
|
||||
// ...
|
||||
)
|
||||
|
||||
var MyMask *MaskBit
|
||||
|
||||
func main() {
|
||||
MyMask = types.NewMaskBit
|
||||
|
||||
MyMask.AddFlag(OPT1)
|
||||
MyMask.AddFlag(OPT3)
|
||||
|
||||
_ = MyMask
|
||||
}
|
||||
|
||||
This would return true:
|
||||
|
||||
MyMask.HasFlag(OPT1)
|
||||
|
||||
As would this:
|
||||
|
||||
MyMask.HasFlag(OPT3)
|
||||
|
||||
But this would return false:
|
||||
|
||||
MyMask.HasFlag(OPT2)
|
||||
*/
|
||||
package bitmask
|
||||
Reference in New Issue
Block a user