utils

package
v0.0.0-...-0871eb3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Atoi

func Atoi(str string) (ret int)

Atoi is to convert string to int

func CheckInterface

func CheckInterface(v interface{}) string

CheckInterface is to check type of interface

func CheckInterfaceByIf

func CheckInterfaceByIf(val interface{}) string

CheckInterfaceByIf is to check type of interface

func CheckRandom

func CheckRandom()

CheckRandom is to display generated random number

func ConvertToInt

func ConvertToInt(arr []string) []int

ConvertToInt string array into int array

func CopySlice

func CopySlice(arr []int) []int

CopySlice is to copy slice

func CopySlice32

func CopySlice32(arr []int32) []int32

CopySlice32 is to copy slice

func DeleteElement

func DeleteElement(arr []int, n int) []int

DeleteElement is to delete number of 2nd parameter from array

func DeleteInt

func DeleteInt(data []int, from, to int) []int

DeleteInt is delete element from array

func DeleteStr

func DeleteStr(data string, from, to int) string

DeleteStr is delete element from array

func GenerateIntData

func GenerateIntData(num int, max int) (values []int)

GenerateIntData is to return randam number of array range is 0 to (max-1)

func GenerateRandom

func GenerateRandom(min, max int) int

GenerateRandom is to generate random number

func GenerateUniquieArray

func GenerateUniquieArray(num, min, max int) []int

GenerateUniquieArray is to generate unique array GenerateUniquieArray(5, 1, 10) may return []{4,7,1,3,9}

func GoPanicWhenError

func GoPanicWhenError(err error)

GoPanicWhenError is to execute panic when error

func IsExistDir

func IsExistDir(name string) bool

IsExistDir is to check existence of directory

func ItoBS

func ItoBS(val interface{}) string

ItoBS is to convert byte[] of interface{} to string

func ItoByte

func ItoByte(val interface{}) []byte

ItoByte is to convert byte[] of interface{} to string

func ItoMsi

func ItoMsi(val interface{}) map[string]int

ItoMsi is to convert map[string] of interface{} to map[string]int

func ItoMsif

func ItoMsif(val interface{}) map[string]interface{}

ItoMsif is to convert map[string] of interface{} to map[string]interface{}

func ItoSI

func ItoSI(val interface{}) []interface{}

ItoSI is to convert map[string] of interface{} to map[string]int

func ItoT

func ItoT(val interface{}) time.Time

ItoT is to convert interface{} to time.Time

func ItoTS

func ItoTS(val interface{}) string

ItoTS is to convert time.Time of interface{} to string

func ItoUI

func ItoUI(val interface{}) uint

ItoUI is to convert interface{} to uint

func Itoa

func Itoa(num int) (ret string)

Itoa is to convert int to string

func Itob

func Itob(val interface{}) bool

Itob is to convert interface{} to bool

func Itoi

func Itoi(val interface{}) int

Itoi is to convert interface{} to int

func Itos

func Itos(val interface{}) string

Itos is to convert interface{} to string

func PickOneFromEnum

func PickOneFromEnum(arr []string) string

PickOneFromEnum is pick one element up from array

func Pop

func Pop(val []interface{}) []interface{}

Pop is to remove element from end of slice

func PopInt

func PopInt(val []int) []int

PopInt is to remove element from end of slice

func PopStr

func PopStr(val string) string

PopStr is to remove element from end of slice

func Push

func Push(base []interface{}, val interface{}) []interface{}

Push is to add element to end of slice

func PushInt

func PushInt(base []int, val int) []int

PushInt is to add element to end of slice

func PushStr

func PushStr(base, val string) string

PushStr is to add element to end of slice

func SearchString

func SearchString(ary []string, str string) int

SearchString is to search string

func SearchStringLower

func SearchStringLower(ary []string, str string) int

SearchStringLower is to search string converted as lower case func SearchStringLower(ary []string, str string) int {

	retIdx := -1
	if len(ary) == 0 {
		return retIdx
	}
	for i, val := range ary {
		if strings.ToLower(val) == strings.ToLower(str) {
			retIdx = i
			break
		}
	}

	return retIdx
}

func Shift

func Shift(val []interface{}) []interface{}

Shift is to remove element from first of slice

func ShiftInt

func ShiftInt(val []int) []int

ShiftInt is to remove element from first of slice

func ShiftStr

func ShiftStr(val string) string

ShiftStr is to remove element from first of slice

func ShowErrorWhenError

func ShowErrorWhenError(err error)

ShowErrorWhenError is to show error when error

func Slice

func Slice(str string, idx ...int) string

Slice is to extract sliced characters str: target string, idx[0]: start index, idx[1]: end index

func SliceIntToInterface

func SliceIntToInterface(dataSlice []int) []interface{}

SliceIntToInterface is to convert slice data of int to slice []interface{} https://github.com/golang/go/wiki/InterfaceSlice

func SliceMapToInterface

func SliceMapToInterface(dataSlice []map[string]int) []interface{}

SliceMapToInterface is to change slice data of map[string]int to slice []interface{}

func SliceStrToInterface

func SliceStrToInterface(dataSlice []string) []interface{}

SliceStrToInterface is to change slice data of string to slice []interface{}

func SortStructSlice

func SortStructSlice()

SortStructSlice is to sort struct slice

func SpliceInt

func SpliceInt(base []int, idx, val int) []int

SpliceInt is to add element to designated index This is like `Insert`

func SpliceStr

func SpliceStr(base, val string, idx int) string

SpliceStr is to add element to designated index This is like `Insert`

func StoType

func StoType(typeStr string) reflect.Kind

StoType is to change string to type

func Stoe

func Stoe(val string) error

Stoe is to convert string to error

func Substr

func Substr(str string, idx ...int) string

Substr is to subtract from str str: target string, idx[0]: start index, idx[1]: length

func SwapInt

func SwapInt(x, y int) (int, int)

SwapInt is to swap parameters

func SwapString

func SwapString(x, y string) (string, string)

SwapString is to swap parameters

func UniqueStringSlice

func UniqueStringSlice(arr []string) (uniq []string)

UniqueStringSlice is to remove overlapped element

func Unshift

func Unshift(base []interface{}, val interface{}) []interface{}

Unshift is to add element to first of slice

func UnshiftInt

func UnshiftInt(base []int, val int) []int

UnshiftInt is to add element to first of slice

func UnshiftStr

func UnshiftStr(base, val string) string

UnshiftStr is to add element to first of slice

Types

This section is empty.

Jump to

Keyboard shortcuts

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