tagparse

package
v0.0.0-...-3ee71c1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2014 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package to parse a tag.

Tags are annotation with struct fields, that allow for some elegant solutions for different problems. Examples are validation and alike. This is an example on what that might look like:

type Example struct {
	AField string `tagName1:"tagValue1" tagName2:"tagValue2"`
}

As the syntax is somewhat weird and the tag interface only supports a getter, this tag parser was written. It will use go's tag parser to retrieve the tag for a given prefix, parse the value, and return a map of strings to strings. Keys and values are separated by an equal sign '=', values might be quoted using single quotes "'", and key-value pairs are separated using whitespace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(field reflect.StructField, prefix string) (result map[string]string, e error)

Parse tag with the given prefix of the given field. Return a map of strings to strings. If errors occur they are returned accordingly.

Types

This section is empty.

Jump to

Keyboard shortcuts

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