# Pointer pointer contains some util functions to operate go pointer.
## Source: - [https://github.com/duke-git/lancet/blob/main/pointer/pointer.go](https://github.com/duke-git/lancet/blob/main/pointer/pointer.go) ## Usage: ```go import ( "github.com/duke-git/lancet/v2/pointer" ) ``` ## Index - [Of](#Of) - [Unwrap](#Unwrap) - [ExtractPointer](#ExtractPointer) ## Documentation ### OfReturns a pointer to the pass value `v`.
Signature: ```go func Of[T any](v T) *T ``` Example: ```go package main import ( "fmt" "github.com/duke-git/lancet/v2/pointer" ) func main() { result1 := pointer.Of(123) result2 := pointer.Of("abc") fmt.Println(*result1) fmt.Println(*result2) // Output: // 123 // abc } ``` ### UnwrapReturns the value from the pointer.
Signature: ```go func Unwrap[T any](p *T) T ``` Example: ```go package main import ( "fmt" "github.com/duke-git/lancet/v2/pointer" ) func main() { a := 123 b := "abc" result1 := pointer.Unwrap(&a) result2 := pointer.Unwrap(&b) fmt.Println(result1) fmt.Println(result2) // Output: // 123 // abc } ``` ### ExtractPointerReturns the underlying value by the given interface type
Signature: ```go func ExtractPointer(value any) any ``` Example: ```go package main import ( "fmt" "github.com/duke-git/lancet/v2/pointer" ) func main() { a := 1 b := &a c := &b d := &c result := pointer.ExtractPointer(d) fmt.Println(result) // Output: // 1 } ```