reflect.Uint() Function in Golang with Examples Last Updated : 10 May, 2020 Comments Improve Suggest changes Like Article Like Report Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Uint() Function in Golang is used to get v's underlying value, as a uint64. To access this function, one needs to imports the reflect package in the program. Syntax: func (v Value) Uint() uint64 Parameters: This function does not accept any parameter. Return Value: This function returns the v's underlying value, as a uint64. Below examples illustrate the use of the above method in Golang: Example 1: C // Golang program to illustrate // reflect.Uint() Function package main import ( "fmt" "reflect" ) func sum(args []reflect.Value) []reflect.Value { a, b := args[0], args[1] if a.Kind() != b.Kind() { fmt.Println("??? ????.") return nil } switch a.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return []reflect.Value{reflect.ValueOf(a.Int() + b.Int())} case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return []reflect.Value{reflect.ValueOf(a.Uint() + b.Uint())} case reflect.Float32, reflect.Float64: return []reflect.Value{reflect.ValueOf(a.Float() + b.Float())} case reflect.String: return []reflect.Value{reflect.ValueOf(a.String() + b.String())} default: return []reflect.Value{} } } func makeSum(fptr interface{}) { fn := reflect.ValueOf(fptr).Elem() v := reflect.MakeFunc(fn.Type(), sum) fn.Set(v) } // Main function func main() { var intSum func(int, int) int64 var floatSum func(float32, float32) float64 var stringSum func(string, string) string makeSum(&intSum) makeSum(&floatSum) makeSum(&stringSum) fmt.Println(intSum(1, 2)) fmt.Println(floatSum(2.1, 3.5)) fmt.Println(stringSum("Geeksfor","Geeks")) } Output: 3 5.599999904632568 GeeksforGeeks Example 2: C // Golang program to illustrate // reflect.Uint() Function package main import ( "fmt" "reflect" ) func sum(args []reflect.Value) []reflect.Value { a, b := args[0], args[1] if a.Kind() != b.Kind() { fmt.Println("??? ????.") return nil } switch a.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return []reflect.Value{reflect.ValueOf(a.Int() + b.Int())} case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return []reflect.Value{reflect.ValueOf(a.Uint() + b.Uint())} case reflect.Float32, reflect.Float64: return []reflect.Value{reflect.ValueOf(a.Float() + b.Float())} case reflect.String: return []reflect.Value{reflect.ValueOf(a.String() + b.String())} default: return []reflect.Value{} } } func makeSum(fptr interface{}) { fn := reflect.ValueOf(fptr).Elem() v := reflect.MakeFunc(fn.Type(), sum) fn.Set(v) } // Main function func main() { var stringSum func(string, string) string makeSum(&stringSum) fmt.Println(stringSum("Value_1 : ","Geeks_1")) } Output: Value_1 : Geeks_1 Comment More infoAdvertise with us Next Article reflect.Uint() Function in Golang with Examples S SHUBHAMSINGH10 Follow Improve Article Tags : Go Language Golang-reflect Similar Reads reflect.Set() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Set() Function in Golang is used to assigns x to the value v. To access this function, one needs to imports the r 2 min read reflect.Type() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Type() Function in Golang is used to get v's type. To access this function, one needs to imports the reflect pack 1 min read reflect.String() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.String() Function in Golang is used to get the string v's underlying value, as a string. To access this function, 2 min read reflect.TypeOf() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package.The reflect.TypeOf() Function in Golang is used to get the reflection Type that represents the dynamic type of i. To access th 1 min read reflect.Int() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Int() Function in Golang is used to get the v's underlying value, as an int64. To access this function, one needs 1 min read Like