tag

package
v0.0.0-...-b05fda7 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package tag provides useful features for manipulating struct field tags.

This is based mostly on stdlib code, copyright 2009 The Go Authors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lookup

func Lookup(tag, key string) (value string, ok bool)

Lookup looks up values in a struct tag, which by convention is a sequence of key:"value" pairs, optionally separated by whitespace. See reflect.StructTag.

Note that, unlike the Go parser and reflect package, struct tag strings in morph are not enclosed with a quote pair like a Go string literal. The input to this function is unquoted.

It returns the value associated with key in the tag string. If the key is present in the tag the value (which may be empty) is returned. Otherwise, the returned value will be the empty string. The ok return value reports whether the value was explicitly set in the tag string. If the tag does not have the conventional format, the value returned by Lookup is unspecified.

func NextPair

func NextPair(tag string) (key, value, rest string, ok bool)

NextPair returns the next key, value, and remaining tag in a struct tag string.

Note that, unlike the Go parser and reflect package, struct tag strings in morph are not enclosed with a quote pair like a Go string literal. The input to this function is unquoted.

The ok return value reports whether the value was explicitly set in the tag string. If the tag does not have the conventional format, the value returned by is unspecified.

func Quote

func Quote(s string) string

Quote is like strconv.Quote, but uses backticks instead of double quotes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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