goutil

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

README

Go 工具库

Build Status Go Report Card license Release GoDoc

Documentation

Overview

Package goutil Go常用工具包

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(filePath string, rw http.ResponseWriter) error

DownloadFile 文件下载

func FormatAppVersion

func FormatAppVersion(appVersion, GitCommit, BuildDate string) (string, error)

FormatAppVersion 格式化应用版本信息

func MD5

func MD5(s string) string

MD5 生成MD5摘要

Example
str := "goutil"
fmt.Println(MD5(str))
Output:

3fa6e676e7d5c558e9a49b599cbc975f

func PanicToError

func PanicToError(f func()) (err error)

PanicToError Panic转换为error

Example
err := PanicToError(func() {
	var m map[string]string
	m["key"] = "value"
})
fmt.Println(err)
Output:

func PanicTrace added in v1.0.3

func PanicTrace(err interface{}) string

PanicTrace panic调用链跟踪

func PrintAppVersion

func PrintAppVersion(appVersion, GitCommit, BuildDate string)

PrintAppVersion 打印应用版本

func RandNumber

func RandNumber(min, max int) int

RandNumber 生成min - max之间的随机数 如果min大于max, panic

Example
num := RandNumber(1, 1000)
fmt.Println(num)
Output:

func WorkDir

func WorkDir() (string, error)

WorkDir 获取程序运行时根目录

Types

type WaitGroupWrapper

type WaitGroupWrapper struct {
	sync.WaitGroup
}

WaitGroupWrapper waitGroup包装

func (*WaitGroupWrapper) Wrap

func (w *WaitGroupWrapper) Wrap(f func())

Wrap 包装Add, Done方法

Directories

Path Synopsis
Package httpclient http客户端
Package httpclient http客户端
Package slice 数组常用操作
Package slice 数组常用操作

Jump to

Keyboard shortcuts

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