util

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2025 License: Apache-2.0 Imports: 3 Imported by: 606

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCommentTagsWithoutArguments added in v0.34.0

func ExtractCommentTagsWithoutArguments(marker string, tagNames []string, lines []string) (map[string][]string, error)

ExtractCommentTagsWithoutArguments parses comments for special metadata tags. The marker argument should be unique enough to identify the tags needed, and should not be a marker for tags you don't want, or else the caller takes responsibility for making that distinction.

The tagNames argument is a list of specific tags being extracted. If this is nil or empty, all lines which match the marker are considered. If this is specified, only lines with begin with marker + one of the tags will be considered. This is useful when a common marker is used which may match lines which fail this syntax (e.g. which predate this definition).

This function looks for input lines of the following forms:

  • 'marker' + "key=value"
  • 'marker' + "key()=value"
  • 'marker' + "key(arg)=value"

The arg is forbidden. This function only consider tags with no arguments specified (either as "key=value" or as // "key()=value"). Finding tags with an argument will result in an error.

The value is optional. If not specified, the resulting Tag will have "" as the value.

Tag comment-lines may have a trailing end-of-line comment.

The map returned here is keyed by the Tag's name without args.

A tag can be specified more than one time and all values are returned. If the resulting map has an entry for a key, the value (a slice) is guaranteed to have at least 1 element.

Example: if you pass "+" for 'marker', and the following lines are in the comments:

+foo=val1   // foo
+bar
+foo=val2   // also foo
+foo()=val3 // still foo
+baz="qux"

Then this function will return:

map[string][]string{"foo":{"val1", "val2", "val3"}, "bar": {""}, "baz": {`"qux"`}}

func PluralExceptionListToMapOrDie added in v0.18.0

func PluralExceptionListToMapOrDie(pluralExceptions []string) map[string]string

PluralExceptionListToMapOrDie converts the list in "Type:PluralType" to map[string]string. This is used for pluralizer. If the format is wrong, this function will panic.

Types

This section is empty.

Jump to

Keyboard shortcuts

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