ptrutil

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 0 Imported by: 0

README

ptrutil

Package ptrutil provides helpers to convert values to pointers and pointers values

Tests

Install

go get github.com/verify-lab/ptrutil

Ptr function example

values := []interface{}{
    "test", 1, true,
}

for _, val := range values {
    fmt.Printf("val: %+v; ptr: %+v\n", val, Ptr(val))
}

// Output:
// val: test; ptr: 0xc000014250
// val: 1;    ptr: 0xc000014260
// val: true; ptr: 0xc000014270

FromPtr function example

val := "test"

fmt.Printf("val: %+v; ptr: %+v\n", val, FromPtr(&val))
// Output:
// val: test; ptr: 0xc000014250

Documentation

Overview

Package ptrutil provides helpers to convert values to pointers and pointers values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromPtr

func FromPtr[T any](v *T) T

FromPtr converts a pointer to a value

func Ptr

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

Ptr converts a value to a pointer

Types

This section is empty.

Jump to

Keyboard shortcuts

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