Standard library / reflect

reflect.Value.SetUint()

Change a settable uint8 value through its kind-specific setter. Wrong kinds or non-settable values panic; numeric conversions may narrow. Expected stdout: '7\n'.

Formal Syntax & Structure

go syntaxgo
func (v Value) SetUint(x uint64)

Parameters & Attributes

NameTypeDescription
xuint64New value; must satisfy the destination kind or assignability requirement.

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() { var x uint8; reflect.ValueOf(&x).Elem().SetUint(7); fmt.Println(x) }
Go Reference