opt

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NullString = String{nil}

NullString represents an empty optional String.

Functions

This section is empty.

Types

type String

type String struct {
	Value *string
}

String holds an optional string value.

func NewNotEmptyString

func NewNotEmptyString(value string) String

NewNotEmptyString creates a new optional String with the given value or returns NullString if the value is an empty string.

func NewString

func NewString(value string) String

NewString creates a new optional String with the given value.

func NewStringWithPtr

func NewStringWithPtr(value *string) String

NewString creates a new optional String with the given pointer. When nil, the String is considered null, but an empty String is valid.

func (String) Equal

func (s String) Equal(other String) bool

func (String) IsEmpty

func (s String) IsEmpty() bool

IsEmpty returns whether the optional String has an empty string for value.

func (String) IsNull

func (s String) IsNull() bool

IsNull returns whether the optional String has no value.

func (String) MarshalJSON

func (s String) MarshalJSON() ([]byte, error)

func (String) NonEmpty

func (s String) NonEmpty() String

NonEmpty returns a null String if the String is empty.

func (String) Or

func (s String) Or(other String) String

Or returns the receiver if it is not null, otherwise the given optional String.

func (String) OrString

func (s String) OrString(alt string) String

OrString returns the optional String value or the given default string if it is null.

func (String) String

func (s String) String() string

func (String) Unwrap

func (s String) Unwrap() string

Unwrap returns the optional String value or an empty String if none is set.

Jump to

Keyboard shortcuts

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