tags

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package tags contains code for parsing struct tags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(k, v string) (bool, error)

A Handler function handles a tag key/value pair. Returns (true, nil) if the tag is handled successfully.

type StructTag

type StructTag string

A StructTag aliases a struct tag string to add parsing functionality.

func (StructTag) ForEach

func (tag StructTag) ForEach(handler Handler) error

ForEach parses tag and iterates over the key/value pairs, passing each to handler. Iteration may be terminated early if handler returns (true, nil). Derived from reflect/type.go Get

func (StructTag) Get

func (tag StructTag) Get(key string) (string, bool)

Get returns the value associated with key in the tag string. If there is no such key in the tag, Get returns ("", false). Similar to reflect/type.go Get, but distinguishes between empty tag values and missing tag keys.

type TagOptions

type TagOptions string

TagOptions is the string following a comma in a struct field's "json" tag, or the empty string. It does not include the leading comma. Copy of unexported type tagOptions from encoding/json/tags.go

func ParseTag

func ParseTag(tag string) (string, TagOptions)

ParseTag splits a struct field's json tag into its name and comma-separated options.

func (TagOptions) Contains

func (o TagOptions) Contains(optionName string) bool

Contains reports whether a comma-separated list of options contains a particular substr flag. substr must be surrounded by a string boundary or commas.

Source Files

  • tags.go

Jump to

Keyboard shortcuts

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