value

package module
v0.0.0-...-c260763 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

README

value

Latest release Build status Go Report Card Documentation

Package value.

go get github.com/go-pogo/value
import "github.com/go-pogo/value"

Documentation

Additional detailed documentation is available at pkg.go.dev

Created with

License

Copyright © 2022 Roel Schut. All rights reserved.

This project is governed by a BSD-style license that can be found in the LICENSE file.

Documentation

Index

Constants

View Source
const (
	ParseError      errors.Kind = "parse error"
	ValidationError errors.Kind = "validation error"
)
View Source
const (
	ErrPointerExpected errors.Msg = "expected a pointer"
	Unsupported                   = "<unsupported>"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Raw

type Raw string

Raw is a raw string representation of a primitive value.

func (Raw) Bool

func (r Raw) Bool() (bool, error)

Bool tries to parse Raw as a bool with strconv.ParseBool and returns it and any errors that occur.

func (Raw) Duration

func (r Raw) Duration() (time.Duration, error)

Duration tries to parse Raw as time.Duration with time.ParseDuration and returns it and any errors that occur.

func (Raw) Float32

func (r Raw) Float32() (float32, error)

Float32 tries to parse Raw as a float32 with strconv.ParseFloat and returns it and any errors that occur.

func (Raw) Float64

func (r Raw) Float64() (float64, error)

Float64 tries to parse Raw as a float64 with strconv.ParseFloat and returns it and any errors that occur.

func (Raw) Int

func (r Raw) Int() (int, error)

Int tries to parse Raw as an int with strconv.ParseInt and returns it and any errors that occur.

func (Raw) Int8

func (r Raw) Int8() (int8, error)

Int8 tries to parse Raw as an int8 with strconv.ParseInt and returns it and any errors that occur.

func (Raw) Int16

func (r Raw) Int16() (int16, error)

Int16 tries to parse Raw as an int16 with strconv.ParseInt and returns it and any errors that occur.

func (Raw) Int32

func (r Raw) Int32() (int32, error)

Int32 tries to parse Raw as an int32 with strconv.ParseInt and returns it and any errors that occur.

func (Raw) Int64

func (r Raw) Int64() (int64, error)

Int64 tries to parse Raw as an int64 with strconv.ParseInt and returns it and any errors that occur.

func (Raw) String

func (r Raw) String() string

String returns Raw as a string.

func (Raw) Uint

func (r Raw) Uint() (uint, error)

Uint tries to parse Raw as an uint with strconv.ParseUint and returns it and any errors that occur.

func (Raw) Uint8

func (r Raw) Uint8() (uint8, error)

Uint8 tries to parse Raw as an uint8 with strconv.ParseUint and returns it and any errors that occur.

func (Raw) Uint16

func (r Raw) Uint16() (uint16, error)

Uint16 tries to parse Raw as an uint16 with strconv.ParseUint and returns it and any errors that occur.

func (Raw) Uint32

func (r Raw) Uint32() (uint32, error)

Uint32 tries to parse Raw as an uint32 with strconv.ParseUint and returns it and any errors that occur.

func (Raw) Uint64

func (r Raw) Uint64() (uint64, error)

Uint64 tries to parse Raw as an uint64 with strconv.ParseUint and returns it and any errors that occur.

type UnsupportedError

type UnsupportedError struct {
	Type string
	Kind reflect.Kind
}

func (*UnsupportedError) Error

func (e *UnsupportedError) Error() string

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value is a wrapper around reflect.Value. It is compatible with the flag.Value and flag.Getter interfaces.

func Must

func Must(v *Value, err error) *Value

func New

func New(val reflect.Value) (*Value, error)

func ValueOf

func ValueOf(ptr interface{}) (*Value, error)

ValueOf creates a Value of the provided pointer to a value. It returns an error with message ErrPointerExpected when ptr is not a pointer.

func (*Value) Get

func (v *Value) Get() interface{}

Get returns Value's current value as an interface{}.

func (*Value) Set

func (v *Value) Set(value string) error

Set sets Value's underlying value by using SetRaw.

func (*Value) SetRaw

func (v *Value) SetRaw(value Raw) error

SetRaw sets Value's underlying value by parsing Raw to Value's underlying reflect.Kind.

func (*Value) String

func (v *Value) String() string

String returns the string representation of Value.

func (*Value) Value

func (v *Value) Value() reflect.Value

Jump to

Keyboard shortcuts

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