text

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

type Hook func(s []byte) error

type Opt

type Opt struct {
	meta.Data

	Value *atomic.Value
	Def   string
	// contains filtered or unexported fields
}

Opt stores a string configuration value

func New

func New(m meta.Data, def string, hook ...Hook) *Opt

New creates a new Opt with a given default value set

func (*Opt) AddHooks

func (x *Opt) AddHooks(hook ...Hook)

AddHooks appends callback hooks to be run when the value is changed

func (*Opt) Bytes

func (x *Opt) Bytes() []byte

Bytes returns the raw bytes in the underlying storage note that this returns a copy because anything done to the slice affects all accesses afterwards, thus there is also a zero function todo: make an option for the byte buffer to be MMU fenced to prevent

elevated privilege processes from accessing this memory.

func (*Opt) Empty

func (x *Opt) Empty() bool

Empty returns true if the string is empty

func (*Opt) GetMetadata

func (x *Opt) GetMetadata() *meta.Data

GetMetadata returns the metadata of the opt type

func (*Opt) LoadInput

func (x *Opt) LoadInput(input string) (o opt.Option, e error)

LoadInput sets the value from a string

func (*Opt) MarshalJSON

func (x *Opt) MarshalJSON() (b []byte, e error)

MarshalJSON returns the json representation

func (*Opt) Name

func (x *Opt) Name() string

Name returns the name of the opt

func (*Opt) ReadInput

func (x *Opt) ReadInput(input string) (o opt.Option, e error)

ReadInput sets the value from a string

func (*Opt) Set

func (x *Opt) Set(s string) (e error)

Set the value stored

func (*Opt) SetBytes

func (x *Opt) SetBytes(s []byte) (e error)

SetBytes sets the string from bytes

func (*Opt) SetHooks

func (x *Opt) SetHooks(hook ...Hook)

SetHooks sets a new slice of hooks

func (*Opt) SetName

func (x *Opt) SetName(name string)

SetName sets the name for the generator

func (*Opt) String

func (x *Opt) String() string

Opt returns a string representation of the value

func (*Opt) Type

func (x *Opt) Type() interface{}

Type returns the receiver wrapped in an interface for identifying its type

func (*Opt) UnmarshalJSON

func (x *Opt) UnmarshalJSON(data []byte) (e error)

UnmarshalJSON decodes a JSON representation

func (*Opt) V

func (x *Opt) V() string

V returns the stored string

func (*Opt) Zero

func (x *Opt) Zero()

Zero the bytes

Jump to

Keyboard shortcuts

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