strutil

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package strutil provides utility functions for working with strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsWord

func ContainsWord(str, word string) bool

ContainsWord returns true if the string contains the (space-separated) full word.

func ExtractVariables

func ExtractVariables(v string) (map[string]bool, error)

ExtractVariables returns a map of variable names found within an input string.

func Filter

func Filter(in []string, p func(string) bool) []string

Filter returns strings that have the provided property.

func FilterNonEmpty

func FilterNonEmpty(in []string) []string

FilterNonEmpty returns the string list with empty strings removed.

func FilterStringsByPrefix

func FilterStringsByPrefix(in []string, prefix string) []string

FilterStringsByPrefix filters returns only strings that do NOT have a given prefix.

func IsImageURL

func IsImageURL(src string) bool

IsImageURL returns true if the format of the string appears to be a URL image.

func IsURL

func IsURL(v string) bool

IsURL returns true if the format of the string appears to be a fully qualified URL

func JoinNonEmpty

func JoinNonEmpty(in []string, separator string) string

JoinNonEmpty filters empty strings and joins remainder together.

func QuoteSplit

func QuoteSplit(str, separator string, stripQuotes bool) []string

QuoteSplit is similiar to strings.Split() but doesn't split within double-quotes.

func ReplaceVariables

func ReplaceVariables(v string, args map[string]string) (string, error)

ReplaceVariables replaces all substrings of the form "${var-name}" based on args like {"var-name":"var-value"}.

func SliceOnlyContains added in v0.8.9

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

SliceOnlyContains checks if the string slice only contains the given string.

func ToTitle

func ToTitle(str string) string

ToTitle does some auto-formatting on camel-cased or snake-cased strings to make them look like titles.

func ToURL

func ToURL(fragment, domain string) string

ToURL returns a fully qualified URL by using domain if it is a relative path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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