Help us shape the future of Go! Take the 2026 Go Developer Survey

paws

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 1 Imported by: 0

README

Paws

GoDoc

Paws provides some helper functions for gopher's developing experience.

Example

package paws_test

import (
	"testing"

	"github.com/mikunalpha/paws"
)

type User struct {
	Email string
	Name  *string
	Age   *int32
}

func TestPaws(t *testing.T) {
	_ = User{
		Email: "user001@email.com",
		Name:  paws.String("user001"),
		Age:   paws.Int32(3),
	}

	var requestEmail *string = nil
	var requestName *string = nil
	var requestAge *int32 = nil
	_ = User{
		Email: paws.MustString(requestEmail, "unknown@email.com"),
		Name:  paws.String(paws.MustString(requestName, "unknown")),
		Age:   requestAge,
	}
}

Documentation

Overview

Package paws provides some helper functions for gopher's developing experience.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) *bool

Bool returns a new pointer of given b bool.

func Float32

func Float32(f float32) *float32

Float32 returns a new pointer of given f float32.

func Float64

func Float64(f float64) *float64

Float64 returns a new pointer of given i float64.

func Int

func Int(i int) *int

Int returns a new pointer of given i int.

func Int8

func Int8(i int8) *int8

Int8 returns a new pointer of given i int8.

func Int16

func Int16(i int16) *int16

Int16 returns a new pointer of given i int16.

func Int32

func Int32(i int32) *int32

Int32 returns a new pointer of given i int32.

func Int64

func Int64(i int64) *int64

Int64 returns a new pointer of given i int64.

func MustBool

func MustBool(p *bool, b bool) bool

MustBool returns a bool value of pointer p, if p is not nil. b is returned, if p is nil.

func MustFloat32

func MustFloat32(p *float32, f float32) float32

MustFloat32 returns a float32 value of pointer p, if p is not nil. f is returned, if p is nil.

func MustFloat64

func MustFloat64(p *float64, f float64) float64

MustFloat64 returns a float64 value of pointer p, if p is not nil. f is returned, if p is nil.

func MustInt

func MustInt(p *int, i int) int

MustInt returns a int value of pointer p, if p is not nil. i is returned, if p is nil.

func MustInt8

func MustInt8(p *int8, i int8) int8

MustInt8 returns int value of pointer p, if p is not nil. i is returned, if p is nil.

func MustInt16

func MustInt16(p *int16, i int16) int16

MustInt16 returns a int value of pointer p, if p is not nil. i is returned, if p is nil.

func MustInt32

func MustInt32(p *int32, i int32) int32

MustInt32 returns a int value of pointer p, if p is not nil. i is returned, if p is nil.

func MustInt64

func MustInt64(p *int64, i int64) int64

MustInt64 returns a int value of pointer p, if p is not nil. i is returned, if p is nil.

func MustString

func MustString(p *string, s string) string

MustString returns a string value of pointer p, if p is not nil. s is returned, if p is nil.

func MustTime added in v1.1.0

func MustTime(p *time.Time, t time.Time) time.Time

MustTime returns a time.Time value of pointer p, if p is not nil. t is returned, if p is nil.

func MustUint

func MustUint(p *uint, u uint) uint

MustUint returns a uint64 value of pointer p, if p is not nil. u is returned, if p is nil.

func MustUint8

func MustUint8(p *uint8, u uint8) uint8

MustUint8 returns a uint8 value of pointer p, if p is not nil. u is returned, if p is nil.

func MustUint16

func MustUint16(p *uint16, u uint16) uint16

MustUint16 returns a uint16 value of pointer p, if p is not nil. u is returned, if p is nil.

func MustUint32

func MustUint32(p *uint32, u uint32) uint32

MustUint32 returns a uint32 value of pointer p, if p is not nil. u is returned, if p is nil.

func MustUint64

func MustUint64(p *uint64, u uint64) uint64

MustUint64 returns a uint64 value of pointer p, if p is not nil. u is returned, if p is nil.

func String

func String(s string) *string

String returns a new pointer of given s string.

func Time added in v1.1.0

func Time(t time.Time) *time.Time

Time returns a new pointer of given i time.Time.

func Uint

func Uint(u uint) *uint

Uint returns a new pointer of given u uint.

func Uint8

func Uint8(u uint8) *uint8

Uint8 returns a new pointer of given u uint8.

func Uint16

func Uint16(u uint16) *uint16

Uint16 returns a new pointer of given u uint16.

func Uint32

func Uint32(u uint32) *uint32

Uint32 returns a new pointer of given u uint32.

func Uint64

func Uint64(u uint64) *uint64

Uint64 returns a new pointer of given u uint64.

func Z2NBool added in v1.2.0

func Z2NBool(b bool) *bool

Z2NBool returns a new pointer of given b bool. If b is zero value, it returns nil.

func Z2NFloat32 added in v1.2.0

func Z2NFloat32(f float32) *float32

Z2NFloat32 returns a new pointer of given f float32. If f is zero value, it returns nil.

func Z2NFloat64 added in v1.2.0

func Z2NFloat64(f float64) *float64

Z2NFloat64 returns a new pointer of given f float64. If f is zero value, it returns nil.

func Z2NInt added in v1.2.0

func Z2NInt(i int) *int

Z2NInt returns a new pointer of given i int. If i is zero value, it returns nil.

func Z2NInt8 added in v1.2.0

func Z2NInt8(i int8) *int8

Z2NInt8 returns a new pointer of given i int8. If i is zero value, it returns nil.

func Z2NInt16 added in v1.2.0

func Z2NInt16(i int16) *int16

Z2NInt16 returns a new pointer of given i int16. If i is zero value, it returns nil.

func Z2NInt32 added in v1.2.0

func Z2NInt32(i int32) *int32

Z2NInt32 returns a new pointer of given i int32. If i is zero value, it returns nil.

func Z2NInt64 added in v1.2.0

func Z2NInt64(i int64) *int64

Z2NInt64 returns a new pointer of given i int64. If u is zero value, it returns nil.

func Z2NString added in v1.2.0

func Z2NString(s string) *string

Z2NString returns a new pointer of given s string. If s is zero value, it returns nil.

func Z2NTime added in v1.2.0

func Z2NTime(t time.Time) *time.Time

Z2NTime returns a new pointer of given t time.Time. If t is zero value, it returns nil.

func Z2NUint added in v1.2.0

func Z2NUint(u uint) *uint

Z2NUint returns a new pointer of given u uint. If u is zero value, it returns nil.

func Z2NUint8 added in v1.2.0

func Z2NUint8(u uint8) *uint8

Z2NUint8 returns a new pointer of given u uint8. If u is zero value, it returns nil.

func Z2NUint16 added in v1.2.0

func Z2NUint16(u uint16) *uint16

Z2NUint16 returns a new pointer of given u uint16. If u is zero value, it returns nil.

func Z2NUint32 added in v1.2.0

func Z2NUint32(u uint32) *uint32

Z2NUint32 returns a new pointer of given u uint32. If u is zero value, it returns nil.

func Z2NUint64 added in v1.2.0

func Z2NUint64(u uint64) *uint64

Z2NUint64 returns a new pointer of given u uint64. If u is zero value, it returns nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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