utils

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: MIT Imports: 12 Imported by: 17

README

utils Build Status Build Status license codecov

utils包提供了一些常用的golang函数

  • MD5 生成md5编码;
  • FileExists 判断文件或是目录是否存在;
  • Merge 合并多个同类型的数据;

安装

go get github.com/issue9/utils

文档

Go Walker GoDoc

版权

本项目采用MIT开源授权许可证,完整的授权说明可在LICENSE文件中找到。

Documentation

Overview

Package utils 一些常用的函数集合。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentDir added in v1.2.0

func CurrentDir() string

CurrentDir 获取`调用者`所在的目录

相当于部分语言的 __DIR__

func CurrentFile added in v1.2.0

func CurrentFile() string

CurrentFile 获取`调用者`所在的文件

相当于部分语言的 __FILE__

func CurrentFunction added in v1.2.0

func CurrentFunction() string

CurrentFunction 获取`调用者`所在的函数名

相当于部分语言的 __FUNCTION__

func CurrentLine added in v1.2.0

func CurrentLine() int

CurrentLine 获取`调用者`所在的行

相当于部分语言的 __LINE__

func CurrentPath added in v1.2.0

func CurrentPath(path string) string

CurrentPath 获取`调用者`所在目录的路径

类似于部分语言的的 __DIR__ + "/" + path

func DumpGoFile added in v1.1.0

func DumpGoFile(path, content string) error

DumpGoFile 输出 Go 源代码到 path

会对源代码作格式化。

func DumpGoSource added in v1.2.0

func DumpGoSource(path string, content []byte) error

DumpGoSource 输出 Go 源码到 path

func FileExists

func FileExists(path string) bool

FileExists 判断文件或是文件夹是否存在

func MD5

func MD5(str string) string

MD5 将一段字符串转换成 md5 编码

func Merge

func Merge(deep bool, elems ...interface{}) error

Merge 合并所有的元素,后一个元素的非零值将取代前一个元素中的值。 deep 是否递归合并子元素。 合并的元素只支持结构体或是结构体指针。

func Round

func Round(v float64) int64

Round 对一个浮点数进行四舍五入取整

func SplitPath

func SplitPath(path string) []string

SplitPath 将路径按分隔符分隔成字符串数组。比如:

/a/b/c  ==>  []string{"a", "b", "c"}

func TraceStack

func TraceStack(level int, msg ...interface{}) (string, error)

TraceStack 返回调用者的堆栈信息

Types

This section is empty.

Jump to

Keyboard shortcuts

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