Standard library / reflect
reflect.Value.SetBool()
Change a settable bool value through its kind-specific setter. Wrong kinds or non-settable values panic; numeric conversions may narrow. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (v Value) SetBool(x bool)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | bool | New value; must satisfy the destination kind or assignability requirement. |
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { var x bool; reflect.ValueOf(&x).Elem().SetBool(true); fmt.Println(x) }