github.com/goki/ki@v1.1.11/bools/README.md (about)

     1  # bools
     2  
     3  package bools does conversion to / from booleans and other go standard types:
     4  
     5  ```Go
     6  // ToFloat32 converts a bool to a 1 (true) or 0 (false)
     7  func ToFloat32(b bool) float32 {
     8  	if b {
     9  		return 1
    10  	}
    11  	return 0
    12  }
    13  
    14  // FromFloat32 converts value to a bool, 0 = false, else true
    15  func FromFloat32(v float32) bool {
    16  	if v == 0 {
    17  		return false
    18  	}
    19  	return true
    20  }
    21  ```
    22  
    23  Other types are: `float64, int, int64, int32` -- you can cast from there as necessary.
    24  
    25  `ToString` and `FromString` are also supported to / from "true" and "false"
    26  
    27