Standard library / reflect
reflect.Value.SetInt()
Change a settable int8 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) SetInt(x int64)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | int64 | New value; must satisfy the destination kind or assignability requirement. |
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { var x int8; reflect.ValueOf(&x).Elem().SetInt(7); fmt.Println(x) }