pointer

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MIT Imports: 1 Imported by: 0

README

pointer

Build Status Go Report Card GoDoc

Documentation

Overview

Package pointer provides helpers to get pointers to values of built-in types.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToBool

func ToBool(in bool) *bool

ToBool gets pointer by bool.

func ToByte

func ToByte(in byte) *byte

ToByte gets pointer to byte.

func ToComplex128

func ToComplex128(in complex128) *complex128

ToComplex128 gets pointer to complex 128.

func ToComplex64

func ToComplex64(in complex64) *complex64

ToComplex64 gets pointer complex64.

func ToDuration

func ToDuration(in time.Duration) *time.Duration

ToDuration get pointer by time.Duration.

Example
package main

import (
	"fmt"
	"time"

	"gitoa.ru/go-4devs/pointer"
)

func main() {
	fmt.Printf("%T, %T", pointer.ToDuration(time.Hour), time.Hour)
}
Output:

*time.Duration, time.Duration

func ToFloat32

func ToFloat32(in float32) *float32

ToFloat32 gets pointer float32.

func ToFloat64

func ToFloat64(in float64) *float64

ToFloat64 gets pointer by float64.

func ToInt

func ToInt(in int) *int

ToInt gets pointer int.

func ToInt16

func ToInt16(in int16) *int16

ToInt16 gets pointer by int16.

func ToInt32

func ToInt32(in int32) *int32

ToInt32 gets pointer int32.

func ToInt64

func ToInt64(in int64) *int64

ToInt64 gets pointer int64.

Example
package main

import (
	"fmt"

	"gitoa.ru/go-4devs/pointer"
)

func main() {
	fmt.Printf("%T", pointer.ToInt64(1))
}
Output:

*int64

func ToInt8

func ToInt8(in int8) *int8

ToInt8 gets pointer int8.

func ToRune

func ToRune(in rune) *rune

ToRune gets pointer rune.

func ToString

func ToString(in string) *string

ToString gets pointer string.

Example
package main

import (
	"fmt"

	"gitoa.ru/go-4devs/pointer"
)

func main() {
	fmt.Printf("%T, %T", pointer.ToString("message"), "message")
}
Output:

*string, string

func ToTime

func ToTime(in time.Time) *time.Time

ToTime get pointer by time.Time.

Example
package main

import (
	"fmt"
	"time"

	"gitoa.ru/go-4devs/pointer"
)

func main() {
	fmt.Printf("%T, %T", pointer.ToTime(time.Now()), time.Now())
}
Output:

*time.Time, time.Time

func ToUint

func ToUint(in uint) *uint

ToUint gets pointer uint.

func ToUint16

func ToUint16(in uint16) *uint16

ToUint16 gets pointer by uint16.

func ToUint32

func ToUint32(in uint32) *uint32

ToUint32 gets pointer by uint32.

func ToUint64

func ToUint64(in uint64) *uint64

ToUint64 gets pointer by uint64.

func ToUint8

func ToUint8(in uint8) *uint8

ToUint8 gets pointer uint8.

func ToUintptr

func ToUintptr(in uintptr) *uintptr

ToUintptr gets pointer by uintptr.

Types

This section is empty.

Jump to

Keyboard shortcuts

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