Documentation
¶
Index ¶
- Constants
- Variables
- func CheckTag(tag string) error
- func IndentString(str, indent string) string
- func IndentStringIn(w io.Writer, str, indent, colOn, colOff string)
- func JSONPointer(v interface{}, pointer string) (interface{}, error)
- func SliceToBuffer(buf *bytes.Buffer, items []reflect.Value) *bytes.Buffer
- func TernRune(cond bool, a, b rune) rune
- func TernStr(cond bool, a, b string) string
- func ToString(val interface{}) string
- func TypeFullName(t reflect.Type) string
- func UnmarshalJSON(buf []byte, target interface{}) error
- type JSONPointerError
Constants ¶
const ( ErrJSONPointerInvalid = "invalid JSON pointer" ErrJSONPointerKeyNotFound = "key not found" ErrJSONPointerArrayNoIndex = "array but not an index in JSON pointer" ErrJSONPointerArrayOutOfRange = "out of array range" ErrJSONPointerArrayBadType = "not a map nor an array" )
Variables ¶
var ( // ErrTagEmpty is the error returned by CheckTag for an empty tag. ErrTagEmpty = errors.New("A tag cannot be empty") // ErrTagInvalid is the error returned by CheckTag for an invalid tag. ErrTagInvalid = errors.New("Invalid tag, should match (Letter|_)(Letter|_|Number)*") )
Functions ¶
func IndentString ¶
IndentString indents str lines (from 2nd one = 1st line is not indented) by indent.
func IndentStringIn ¶ added in v1.2.0
IndentStringIn indents str lines (from 2nd one = 1st line is not indented) by indent and write it to w. Before each end of line, colOff is inserted, and after each indent on new line, colOn is inserted.
func JSONPointer ¶ added in v1.8.0
JSONPointer returns the value corresponding to JSON pointer "pointer" in "v" as RFC 6901 specifies it. To be searched, "v" has to contains map[string]interface{} or []interface{} values. All other types fail to be searched.
func SliceToBuffer ¶
SliceToBuffer stringifies items slice into buf then returns buf.
func TypeFullName ¶ added in v1.8.0
TypeFullName returns the t type name with packages fully visible instead of the last package part in t.String().
func UnmarshalJSON ¶ added in v1.1.1
UnmarshalJSON is a custom json.Unmarshal function allowing to handle placeholders not enclosed in strings. It relies on json.SyntaxError errors detected before any memory allocation. So the performance should not be too bad, avoiding to implement our own JSON parser...
Types ¶
type JSONPointerError ¶ added in v1.8.0
func (*JSONPointerError) Error ¶ added in v1.8.0
func (e *JSONPointerError) Error() string