utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvInt2Str

func ConvInt2Str(str int) string

func ConvStr2Int

func ConvStr2Int(str string) int

func CpuPprof

func CpuPprof()

func CreateDir

func CreateDir(dir string)

func Exist

func Exist(filename string) bool

func FileExists

func FileExists(path string) bool

FileExists reports whether the named file or directory exists. 判断所给路径文件/文件夹是否存在

func Get

func Get(url string) string

func GetCurrentPath

func GetCurrentPath() string

func GetExecDir

func GetExecDir() string

func GetFirstDateOfMonth

func GetFirstDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。

func GetLastDateOfMonth

func GetLastDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。

func GetParentDirectory added in v1.0.1

func GetParentDirectory(dir string) string

上级目录

func GetRootPath

func GetRootPath() string

获取项目根目录

func GetZeroTime

func GetZeroTime(d time.Time) time.Time

获取某一天的0点时间

func GrepFile

func GrepFile(patten string, filename string) (lines []string, err error)

GrepFile like command grep -E for example: GrepFile(`^hello`, "hello.txt") \n is striped while read

func IsFileExist added in v1.0.1

func IsFileExist(f string) bool

判断文件是否存在

func JsonDecode

func JsonDecode(data string, v interface{}) error

func JsonEncode

func JsonEncode(v interface{}) (string, error)

func MathDecimal

func MathDecimal(value float64) float64

浮点保留2位小数

func PostForm

func PostForm(url string, json_input interface{}) (string, *http.Response, []error)

表单提交

func PostJson

func PostJson(url string, json_input interface{}) (string, *http.Response, []error)

json提交

json_input := map[string]interface{}{
	"name": "backy",
	"species": "dog",
}

json_input := `{"name":"backy", "species":"dog"}`

func PrintType

func PrintType(s interface{})

打印值和类型

func PrintVal

func PrintVal(s interface{})

打印值

func ReadFile

func ReadFile(fileName string) (data []byte)

func SearchFile

func SearchFile(filename string, paths ...string) (fullpath string, err error)

SearchFile Search a file in paths. this is often used in search config file in /etc ~/

func SelfDir

func SelfDir() string

SelfDir gets compiled executable file directory

func SelfPath

func SelfPath() string

SelfPath gets compiled executable file absolute path

func WriteFile

func WriteFile(filename string, data string) bool

WriteFile

Types

This section is empty.

Jump to

Keyboard shortcuts

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