structtag

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package structtag parses the value of a single struct tag into its name and options. It targets the near-universal `name,opt1,opt2` encoding used by encoding/json, gopkg.in/yaml.v3 and most reflection-based decoders, so it is not tied to any one tag key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options map[string]struct{}

Options is the set of comma-separated options that follow the name in a struct tag value (for example "omitempty" or "inline").

func Parse

func Parse(tag string) (string, Options)

Parse splits a struct tag value of the form "name,opt1,opt2" into the name and the set of options. An empty name means the tag carried no explicit name (for example ",inline" or the empty tag), leaving it to the caller to fall back to the field name.

func (Options) Has

func (o Options) Has(opt string) bool

Has reports whether opt is present in the set.

Jump to

Keyboard shortcuts

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