ptrs

package
v0.0.0-...-3511abf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ptr

func Ptr[T any](t T) *T

Ptr returns a pointer to a copy of a value. This lets you take the address of some non-addressable[1] values, like boolean literals. So if a struct has a *bool field, you can do:

x := MyStruct{MyBool: Ptr(true)}

instead of:

temp := true
x := MyStruct{MyBool: &temp}

[1] https://go.dev/ref/spec#Address_operators

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL