inflect

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

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

Go to latest
Published: May 21, 2017 License: MIT Imports: 2 Imported by: 3 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

inflect

common reflection operations (get, set, tag, cas) for a struct field

Please see tests.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("field does not exist")
	ErrNotMatched   = errors.New("CAS old value does not match")
	ErrInvalidType  = errors.New("data has invalid type - not a pointer nor a struct")
	ErrNonPointer   = errors.New("a pointer was expected")
	ErrNoSet        = errors.New("can not set field value")
	ErrTypeMismatch = errors.New("field type & value type are different")
)

Errors

Functions

func CAS

func CAS(data interface{}, fieldName string, oldValue, newValue interface{}) error

CAS compares field's value with an old value and sets it to new value if it matches

func Get

func Get(data interface{}, fieldName string) (interface{}, error)

Get extracts the value of a field

func Set

func Set(data interface{}, fieldName string, value interface{}) error

Set accepts a pointer and sets the field value

func Tag

func Tag(data interface{}, fieldName string, tag string) (string, error)

Tag extract a tag & returns it's values for a field

Types

This section is empty.

Directories

Path Synopsis
Package inflectlab is an incubator for ideas/tools
Package inflectlab is an incubator for ideas/tools

Jump to

Keyboard shortcuts

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