list

package
v0.0.0-...-6a2a004 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package list provides a string slice abstraction.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

View Source
const All = "*"

Variables

View Source
var (
	True  = "true"
	False = "false"
)

True and False specify boolean string representations.

View Source
var Bool = map[string]string{
	"true":    True,
	"yes":     True,
	"on":      True,
	"enable":  True,
	"false":   False,
	"no":      False,
	"off":     False,
	"disable": False,
}

Bool specifies boolean string values so they can be normalized.

View Source
var StringLengthLimit = 767

StringLengthLimit specifies the maximum length of string return values.

Functions

func Add

func Add(list []string, s string) []string

Add adds a string to the list if it does not exist yet.

func Contains

func Contains(list []string, s string) bool

Contains tests if a string is contained in the list.

func ContainsAny

func ContainsAny(l, s []string) bool

ContainsAny tests if two lists have at least one common entry.

func Excludes

func Excludes(list []string, s string) bool

Excludes tests if a string is not contained in the list.

func ExcludesAny

func ExcludesAny(l, s []string) bool

ExcludesAny tests if two lists exclude each other.

func Join

func Join(list []string, join []string) []string

Join combines two lists without adding duplicates.

func Key

func Key(s string) string

Key returns the sanitized attribute key.

func Remove

func Remove(list []string, s string) []string

Remove removes a string from a list and returns it.

func Value

func Value(s string) string

Value returns the sanitized attribute value.

Types

type Attr

type Attr []*KeyValue

Attr represents a list of key-value attributes.

func ParseAttr

func ParseAttr(s string) Attr

ParseAttr parses a string into a new Attr slice and returns it.

func (Attr) Contains

func (list Attr) Contains(s string) bool

Contains tests if the list contains the attribute provided as string.

func (Attr) Find

func (list Attr) Find(s string) (a KeyValue)

Find returns the matching KeyValue attribute if found.

func (Attr) Sort

func (list Attr) Sort() Attr

Sort sorts the attributes by key.

func (Attr) String

func (list Attr) String() string

String returns the attributes as string.

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

KeyValue represents a key-value attribute.

func ParseKeyValue

func ParseKeyValue(s string) *KeyValue

ParseKeyValue creates a new key-value attribute from a string.

func (*KeyValue) Parse

func (f *KeyValue) Parse(s string) *KeyValue

Parse parses a string attribute into key and value.

func (*KeyValue) String

func (f *KeyValue) String() string

String return the attribute as string.

type List

type List []string

List represents a list of strings e.g. tags or terms.

Jump to

Keyboard shortcuts

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