goutil

package module
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: Apache-2.0 Imports: 15 Imported by: 6

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 Daemon added in v1.1.3

func Daemon(w io.Writer)

Daemon 守护进程

func DownloadFile

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

DownloadFile 文件下载

func FormatAppVersion

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

FormatAppVersion 格式化应用版本信息

func PanicToError

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

PanicToError Panic转换为error

Example
err := PanicToError(func() {
	panic("error")
})
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 environment 环境
Package environment 环境
Package httpclient http客户端
Package httpclient http客户端
Package slice 数组常用操作
Package slice 数组常用操作
Package version 版本
Package version 版本

Jump to

Keyboard shortcuts

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