github.com/cilium/statedb@v0.3.2/index/bool.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package index
     5  
     6  import "strconv"
     7  
     8  var (
     9  	trueKey  = []byte{'T'}
    10  	falseKey = []byte{'F'}
    11  )
    12  
    13  func Bool(b bool) Key {
    14  	if b {
    15  		return trueKey
    16  	}
    17  	return falseKey
    18  }
    19  
    20  func BoolString(s string) (Key, error) {
    21  	b, err := strconv.ParseBool(s)
    22  	return Bool(b), err
    23  }