tags

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxLengthValidator

func MaxLengthValidator(maxTagLength int) func([]string) error

MaxLengthValidator returns a validator for AddValidated that rejects tags that are longer than maxTagLength characters, counted as Unicode code points rather than bytes, and tags that are not valid UTF-8. The error lists all the offending tags at once. A maxTagLength of zero or less disables the length check, but invalid UTF-8 is still rejected.

Types

type Tags

type Tags struct {
	// contains filtered or unexported fields
}

Tags is a helper struct for merging, deleting and deduplicating the tags while preserving the order

func New

func New(ts ...string) *Tags

New creates a Tag struct from a slice of tags, e.g. ["tag1", "tag2"] or a list of tags, e.g. "tag1,tag2"

func (*Tags) Add

func (t *Tags) Add(ts ...string) bool

Add appends a list of new tags and returns true if at least one was appended

func (*Tags) AddValidated

func (t *Tags) AddValidated(validator func([]string) error, ts ...string) (bool, error)

AddValidated works like Add, but first passes the normalized tags to the given validator: if it returns an error, no tag is added and the error is returned, e.g. to reject a request that contains a tag that is too long.

func (*Tags) AsList

func (t *Tags) AsList() string

AsList returns the tags converted to a list

func (*Tags) AsSlice

func (t *Tags) AsSlice() []string

AsSlice returns the tags as slice of strings

func (*Tags) Remove

func (t *Tags) Remove(s ...string) bool

Remove removes a list of tags and returns true if at least one was removed

Jump to

Keyboard shortcuts

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