reflect.PtrTo() Function in Golang with Examples Last Updated : 28 Apr, 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.PtrTo() Function in Golang is used to get the pointer type with element t, i.e., t represents type Geek, PtrTo(t) represents *Geek. To access this function, one needs to imports the reflect package in the program. Syntax: func PtrTo(t Type) Type Parameters: This function takes only one parameters of Type type(t). Return Value: This function returns the pointer type with element t. Below examples illustrate the use of above method in Golang: Example 1: C // Golang program to illustrate // reflect.PtrTo() Function package main import ( "fmt" "reflect" ) // Main function func main() { ta := reflect.ArrayOf(5, reflect.TypeOf(123)) // use of PtrTo method tp := reflect.PtrTo(ta) fmt.Println(tp) } Output: *[5]int Example 2: C // Golang program to illustrate // reflect.PtrTo() Function package main import ( "fmt" "reflect" ) // Main function func main() { v := reflect.TypeOf("123") // use of PtrTo method fmt.Println(reflect.PtrTo(v)) } Output: *string Comment More infoAdvertise with us Next Article reflect.PtrTo() Function in Golang with Examples S SHUBHAMSINGH10 Follow Improve Article Tags : Go Language Golang-reflect Similar Reads reflect.Pointer() 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.Pointer() Function in Golang is used to get the v's value as a uintptr. To access this function, one needs to imp 2 min read reflect.MapOf() 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.MapOf() Function in Golang is used to get the map type with the given key and element types, i.e., if k represent 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 reflect.IsZero() 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.IsZero() Function in Golang is used to check whether v is the zero value for its type. To access this function, o 1 min read reflect.New() 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.New() Function in Golang is used to get the Value representing a pointer to a new zero value for the specified typ 2 min read reflect.NewAt() 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.NewAt() Function in Golang is used to get the Value representing a pointer to a value of the specified type, usin 2 min read reflect.Indirect() 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.Indirect() Function in Golang is used to get the value that v points to, i.e., If v is a nil pointer, Indirect re 2 min read reflect.Len() 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.Len() Function in Golang is used to get the v's length. To access this function, one needs to imports the reflect 1 min read reflect.Interface() 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.Interface() Function in Golang is used to get the v's current value as an interface{}. To access this function, o 2 min read reflect.NumMethod() 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.NumMethod() Function in Golang is used to get the number of exported methods in the value's method set. To access 2 min read Like