strings

package
v9.1.81+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: MIT Imports: 8 Imported by: 27

Documentation

Overview

Package strutil provides various utilities for manipulating strings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InterpolateString

func InterpolateString(val string, env map[string]interface{}) (string, error)

InterpolateString will replace { } in string

func JoinURL

func JoinURL(elem ...string) string

JoinURL Creates a URL string from parts

func NewUUIDV4

func NewUUIDV4() string

NewUUIDV4 returns a new UUID v4

func PadLeft

func PadLeft(str string, length int, pad byte) string

PadLeft returns a new string of a specified length in which the beginning of the current string is padded with spaces or with a specified Unicode character.

func PadRight

func PadRight(str string, length int, pad byte) string

PadRight returns a new string of a specified length in which the end of the current string is padded with spaces or with a specified Unicode character.

func Pointer

func Pointer(v interface{}) *string

Pointer will return a pointer to a string handling empty string as nil

func PrettyTime

func PrettyTime(t time.Duration) string

PrettyTime returns the string representation of the duration. It rounds the time duration to a second and returns a "---" when duration is 0

func Resize

func Resize(s string, length uint) string

Resize resizes the string with the given length. It ellipses with '...' when the string's length exceeds the desired length or pads spaces to the right of the string when length is smaller than desired

func SortCopy

func SortCopy(arr []string) []string

SortCopy sort an identical copy of the array passed in

func Value

func Value(v interface{}) string

Value returns a string value for an interface or empty string if nil

Types

type CloseableStringReader

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

CloseableStringReader is a string reader which implements the io.ReadCloser interface

func NewCloseableStringReader

func NewCloseableStringReader(input string) *CloseableStringReader

NewCloseableStringReader will return a closeable reader

func (*CloseableStringReader) Close

func (r *CloseableStringReader) Close() error

Close will do nothing

func (*CloseableStringReader) Read

func (r *CloseableStringReader) Read(b []byte) (n int, err error)

Read will reader from buffer

Jump to

Keyboard shortcuts

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