tag

package
v0.0.0-...-e00d658 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package tag provides a way to parse conventionally structured struct tags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StructTag

type StructTag struct {
	// Name of the tag. This must not be unique.
	Name string
	// Values are comma separated
	Values []string
}

A StructTag represents a conventional go struct tag, as specified by reflect.StructTag. Keep in mind that this is just a convention which is not enforced by the compiler and the spec only requires an arbitrary string literal (see https://golang.org/ref/spec#Struct_types).

type Tags

type Tags []StructTag

func Parse

func Parse(tagStr string) Tags

Parse inspects the given string and returns a slice of StructTag. Because the specification does not enforce a specific format, we will never return an error. Unparseable struct tags are silently ignored. The comma separated values are trimmed.

func (Tags) ByName

func (t Tags) ByName(name string) int

ByName returns the index of the first StructTag or -1

func (Tags) Names

func (t Tags) Names() []string

Names returns a sorted list of unique names.

Jump to

Keyboard shortcuts

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