Standard library / reflect

reflect.PointerTo()

Construct the pointer type whose element is t. It does not allocate an object. Expected stdout: '*int\n'.

Formal Syntax & Structure

go syntaxgo
func PointerTo(t Type) Type

Parameters & Attributes

NameTypeDescription
tTypeElement type of the new composite type.

Return Value

Type

Construct the pointer type whose element is t.

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() { fmt.Println(reflect.PointerTo(reflect.TypeOf(0))) }
Go Reference