ptr

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ptr provides a set of SQL compatible pointer helpers

Index

Constants

This section is empty.

Variables

View Source
var (
	// False is the false pointer
	False = Bool(false)

	// True is the true pointer
	True = Bool(true)
)

Functions

func Bool

func Bool(s interface{}) *bool

Bool returns s safely as *bool

func Duration

func Duration(t interface{}) *time.Duration

Duration converts t to a *time.Duration

func First added in v0.1.1

func First(ptrs ...interface{}) interface{}

First returns the first non-nil ptr

func Int

func Int(i interface{}) *int

Int returns i safely as *int

func Int64

func Int64(i interface{}) *int64

Int64 returns i safely as *int64

func NilString

func NilString(s interface{}) *string

NilString returns s safely as *string If string is empty "", nil is returned

func String

func String(s interface{}) *string

String returns s safely as *string

func Time

func Time(t interface{}) *time.Time

Time converts t to a *time.Time

func Uint64 added in v0.1.2

func Uint64(u interface{}) *uint64

Int64 returns i safely as *int64

Types

type JSON

type JSON struct {
	json.RawMessage
	// contains filtered or unexported fields
}

JSON is json pointer

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON marshals the object to json

func (*JSON) Scan

func (j *JSON) Scan(value interface{}) error

Scan reads a json value from the database into a Map

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value returns Map as a value that can be stored as json in the database

type Pointers

type Pointers interface {
	Int() *int
	Int64() *int64
	Uint64() *uint64
	Bool() *bool
	String() *string
	NilString() *string
	Time() *time.Time
	Duration() *time.Duration
}

Pointers provides casting and de-referencing support for scalar values

func Pointer

func Pointer(v interface{}) Pointers

Pointer returns a new Pointers for the value

Jump to

Keyboard shortcuts

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