str

package module
v0.0.0-...-eba1fe2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Empty   = ""
	Space   = " "
	NewLine = "\n"
)
View Source
const (
	BYTE = 1.0 << (10 * iota)
	KILOBYTE
	MEGABYTE
	GIGABYTE
	TERABYTE
)

Variables

This section is empty.

Functions

func BoolMapYesOrNo

func BoolMapYesOrNo(b bool) string

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes format bytes unit

func RemoveEmpty

func RemoveEmpty(str []string) []string

func RepeatSpace

func RepeatSpace(times ...int) string

func Substring

func Substring(source string, start int, end int) string

Substring source[start:end)

func ToInt

func ToInt(val string) int

ToInt cast string to int,default 0

func Truncate

func Truncate(s string, size int) string

Truncate truncate string

func Wrap

func Wrap(left, right, s string) string

Wrap left + s + right

func WrapSpace

func WrapSpace(s string) string

WrapSpace " " + s + " "

Types

type FluentStringBuilder

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

FluentStringBuilder is strings.Builder wrapper, but its api is fluent.

func NewFluent

func NewFluent() *FluentStringBuilder

NewFluent new fluent string builder

func (*FluentStringBuilder) Bool

func (*FluentStringBuilder) Brackets

Brackets wrap ( s )

func (*FluentStringBuilder) Join

func (*FluentStringBuilder) Joins

func (b *FluentStringBuilder) Joins(elems []fmt.Stringer, sep string) *FluentStringBuilder

Joins concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string.

func (*FluentStringBuilder) Len

func (b *FluentStringBuilder) Len() int

Len returns the number of accumulated bytes; b.Len() == len(b.String()).

func (*FluentStringBuilder) NewLine

NewLine append NewLine

func (*FluentStringBuilder) Space

func (b *FluentStringBuilder) Space(times ...int) *FluentStringBuilder

Space append Space

func (*FluentStringBuilder) Str

Str append string

func (*FluentStringBuilder) String

func (b *FluentStringBuilder) String() string

func (*FluentStringBuilder) Strp

Strp append string

func (*FluentStringBuilder) WithSlice

func (b *FluentStringBuilder) WithSlice(slice []string, mapper func(idx int, item string) string) *FluentStringBuilder

WithSlice traverse slice and call mapper

func (*FluentStringBuilder) WrapSpace

WrapSpace " " + s + " "

func (*FluentStringBuilder) Write

func (b *FluentStringBuilder) Write(p []byte) (n int, err error)

func (*FluentStringBuilder) WriteFunc

WriteFunc call f get string and write into FluentStringBuilder.

type WriteFunc

type WriteFunc func(fluent *FluentStringBuilder)

Jump to

Keyboard shortcuts

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