tags

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Hidden = `hidden`

Variables

View Source
var DefaultFilter = Tags{Hidden: Not}
View Source
var Re = regexp.MustCompile(`[+-]?[a-zA-Z][a-zA-Z0-9_]*`)

Note: left-most regexp means we match the "-" if it is present

Functions

func AddTag

func AddTag(tags Tags, tag string) string

Add tags and return as a query string

func DelTag

func DelTag(tags Tags, tag string) string

func TagsSqlFilter

func TagsSqlFilter(tags Tags) (string, []any)

Filters according to OR-ing positive tags (not beginning with '-'), removing negative tags (beginning with '-')

Types

type TagType

type TagType string
const (
	Not TagType = "-"
	All TagType = "+"
	Any TagType = ""
)

Ordered in which one has highest precedence

func ParseTag

func ParseTag(tag string) (string, TagType)

Parse tag into type (-/+/none) and body

type Tags

type Tags map[string]TagType

func NormalizeTags

func NormalizeTags(tagsSlice []string) Tags

Becaue the array might be from e.g. tags=foo+bar&tags=baz, first join, then split again. Then remove duplicates, have "-tag" remove "+tag" and "tag", have "+tag" remove "tag"

func (Tags) String

func (tags Tags) String() string

Jump to

Keyboard shortcuts

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