aghstrings

package
v0.106.0-b.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package aghstrings contains utilities dealing with strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneSlice

func CloneSlice(a []string) (b []string)

CloneSlice returns the exact copy of a.

func CloneSliceOrEmpty

func CloneSliceOrEmpty(a []string) (b []string)

CloneSliceOrEmpty returns the copy of a or empty strings slice if a is nil.

func FilterOut

func FilterOut(strs []string, f func(s string) (ok bool)) (filtered []string)

FilterOut returns a copy of strs with all strings for which f returned true removed.

func InSlice

func InSlice(strs []string, str string) (ok bool)

InSlice checks if string is in the slice of strings.

func IsCommentOrEmpty

func IsCommentOrEmpty(s string) (ok bool)

IsCommentOrEmpty returns true of the string starts with a "#" character or is an empty string.

func SplitNext

func SplitNext(s *string, sep rune) (chunk string)

SplitNext splits string by a byte and returns the first chunk skipping empty ones. Whitespaces are trimmed.

func WriteToBuilder

func WriteToBuilder(b *strings.Builder, strs ...string)

WriteToBuilder is a convenient wrapper for strings.(*Builder).WriteString that deals with multiple strings and ignores errors that are guaranteed to be nil.

Types

type Set

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

Set is a set of strings.

func NewSet

func NewSet(strs ...string) (set *Set)

NewSet returns a new string set containing strs.

func (*Set) Add

func (set *Set) Add(s string)

Add adds s to the set. Add panics if the set is a nil set, just like a nil map does.

func (*Set) Del

func (set *Set) Del(s string)

Del deletes s from the set. Calling Del on a nil set has no effect, just like delete on an empty map doesn't.

func (*Set) Has

func (set *Set) Has(s string) (ok bool)

Has returns true if s is in the set. Calling Has on a nil set returns false, just like indexing on an empty map does.

func (*Set) Len

func (set *Set) Len() (n int)

Len returns the length of the set. A nil set has a length of zero, just like an empty map.

func (*Set) Values

func (set *Set) Values() (strs []string)

Values returns all values in the set. The order of the values is undefined. Values returns nil if the set is nil.

Jump to

Keyboard shortcuts

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