Back to godoc.org

Package str

v0.2.2
Latest Go to latest

The highest tagged major version is .

Published: Jul 18, 2020 | License: Apache-2.0 | Module: cuelang.org/go

Overview

Package str provides string manipulation utilities.

Index

func Contains

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

Contains reports whether x contains s.

func FoldDup

func FoldDup(list []string) (string, string)

FoldDup reports a pair of strings from the list that are equal according to strings.EqualFold. It returns "", "" if there are no such strings.

func HasFilePathPrefix

func HasFilePathPrefix(s, prefix string) bool

HasFilePathPrefix reports whether the filesystem path s begins with the elements in prefix.

func HasPathPrefix

func HasPathPrefix(s, prefix string) bool

HasPath reports whether the slash-separated path s begins with the elements in prefix.

func SplitQuotedFields

func SplitQuotedFields(s string) ([]string, error)

SplitQuotedFields splits s into a list of fields, allowing single or double quotes around elements. There is no unescaping or other processing within quoted fields.

func StringList

func StringList(args ...interface{}) []string

StringList flattens its arguments into a single []string. Each argument in args must have type string or []string.

func ToFold

func ToFold(s string) string

ToFold returns a string with the property that

strings.EqualFold(s, t) iff ToFold(s) == ToFold(t)

This lets us test a large set of strings for fold-equivalent duplicates without making a quadratic number of calls to EqualFold. Note that strings.ToUpper and strings.ToLower do not have the desired property in some corner cases.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier