str

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Helper functions for handling strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanUp added in v0.13.0

func CleanUp(str string) string

CleanUp removes extra spaces and trims the input string

func Contains

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

Contains Checks if given string exists in the slice.

func ContainsIgnorecase

func ContainsIgnorecase(slice []string, s string) bool

ContainsIgnorecase Checks if given string exists in the slice. Case insensitive.

func FindIndex

func FindIndex(slice []string, s string) (int, bool)

FindIndex Finds the index of first occurrence of the given value and returns the index and a boolean. Boolean is true when index is found, otherwise index = -1.

func GetIndex added in v0.24.0

func GetIndex(slice []string, s string) int

GetIndex Finds the index of first occurrence of the given string and returns the index. If not found index = -1.

func GetIndexIgnoreCase added in v0.24.0

func GetIndexIgnoreCase(slice []string, s string) int

GetIndexIgnoreCase Finds the index of first occurrence of the given string while ignoring the case and returns the index. If not found index = -1.

func GetString added in v0.27.2

func GetString(path, env string) (response string, err error)

Loads a string from given path with given ENV as failsafe

func Insert added in v0.2.3

func Insert(slice []string, idx int, val string) []string

Insert Inserts given string to given index into a slice.

func Remove added in v0.2.3

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

Remove Removes the first occurence of given string from a slice.

func RemoveFrom added in v0.2.3

func RemoveFrom(slice []string, s int) []string

RemoveFrom Removes a string from given index.

func ReplaceNil added in v0.24.2

func ReplaceNil(s string, t *string) string

Replaces nil valued *string with given string

func Select added in v0.21.1

func Select(condition bool, i1, i2 string) string

Returns i1 if condition == TRUE, else returns i2

func SwitchIf added in v0.21.0

func SwitchIf(condition bool, i1, i2 string) (string, string)

Returns the given values without changes, if condition == FALSE. Returns the values in switched order, if condition == TRUE.

func ToSnakeCase added in v0.2.3

func ToSnakeCase(str string) string

Converts string to SnakeCase.

func Unique

func Unique(t []string) []string

Unique Returns unique strings from given slice of strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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