goutils

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: MIT Imports: 8 Imported by: 9

README

goutils

Common utilities for golang

GoDoc Go Report Card

Documentation

Index

Constants

View Source
const EmptyStr = ""

EmptyStr is the empty string const

Variables

This section is empty.

Functions

func Between

func Between(s, from, to string) string

Between return the middle part of a string from string "from" to string "to"

func Contains

func Contains(obj interface{}, v ...interface{}) bool

Contains tells an object is in a list or not

func DeepContains

func DeepContains(obj interface{}, v ...interface{}) bool

DeepContains tells an object is in a list or not, but uses reflect.DeepEqual to determine the equality

func Download

func Download(url string, dest string) (err error)

Download is used to conveniently download a file to the certain path

func Index

func Index(s, substr string) int

Index return the location of a string in another long string, if it doesn't exist, returns -1 this function supports CJK characters

func IsBlank

func IsBlank(s string) bool

IsBlank tells a string is blank or not, a string with all white blanks would be considered as true

func IsDir

func IsDir(path string) bool

IsDir tells a path is a directory or not

func IsEmpty

func IsEmpty(s string) bool

IsEmpty tells a string is empty or not

func IsExist

func IsExist(path string) bool

IsExist is used to determine whether a path exists or not

func IsFile

func IsFile(path string) bool

IsFile tells a path is a file or not

func IsNotBlank

func IsNotBlank(s string) bool

IsNotBlank tells a string is not blank or is

func IsNotEmpty

func IsNotEmpty(s string) bool

IsNotEmpty tells a string is not empty or is

func LeftPad

func LeftPad(s string, padStr string, length int) string

LeftPad pad a string with specified character to the left side

func Len

func Len(s string) int

Len returns the length of a string using rune, it's useful when getting the length of a string including CJK characters

func RightPad

func RightPad(s string, padStr string, length int) string

RightPad pad a string with specified character to the right side

func ToInt

func ToInt(s string) int

ToInt safely parse a string to a integer with a default value 0 when parse fails

func ToIntDv

func ToIntDv(s string, dv int) int

ToIntDv safely parse a string to a integer with a specified default value

func Trim

func Trim(str string) string

Trim cuts the blanks of a string, the beginning and the end

func TrimLeft

func TrimLeft(str string) string

TrimLeft cuts the left side blanks of a string

func TrimRight

func TrimRight(str string) string

TrimRight cuts the right side blanks of a string

func UUID

func UUID() string

UUID returns a random generated UUID string

func ZeroFill

func ZeroFill(s string, length int) string

ZeroFill pad a string(usually a number string) with "0" to the left

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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