utils

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 25 Imported by: 2

README

github.com/thehappymouse/go-utils

项目介绍

集工作、学习中的的通用工具方法

使用说明

方式一

# go get -u github.com/thehappymouse/go-util

或者使用 mod 

require (
	github.com/magiconair/properties v1.8.1
	github.com/rs/zerolog v1.14.3
	github.com/thehappymouse/go-utils v0.0.2
)

# 代码文件
import "github.com/thehappymouse/go-utils"
# 命令行打印
utils.ZeroConsoleLog()

方试二

# cat go.mod
module modulename

go 1.12

require (
	github.com/magiconair/properties v1.8.1
	github.com/rs/zerolog v1.14.3
	github.com/thehappymouse/go-utils v0.0.2
)

内容简述
  • 36进制
  • zero.log 命令行输出格式化
  • http 下载文件

Documentation

Index

Constants

View Source
const (
	DataTimeMilli  = "2006-01-02T15:04:05.000"
	DataTimeMilli2 = "2006-01-02T150405.000"
	DateTimeDate   = "20060102"
)

Variables

This section is empty.

Functions

func BHex2Num

func BHex2Num(str string, n int) int

36进制数转换 n 表示进制, 16 or 36

func CheckError

func CheckError(err error)

带退出的Log方法

func CopyFile added in v0.0.7

func CopyFile(src, dst string) (int64, error)

通过文件路径复制文件

func DownLoadImgToDir

func DownLoadImgToDir(src string, localDir string) (filename string, err error)

下载文件到指定的目录

func ExtractString

func ExtractString(c []byte, r *regexp.Regexp) string

根据正则,返回匹配的字符串

func GetMoney added in v0.0.7

func GetMoney(v string) string

千分位展示

func HttpGetFile

func HttpGetFile(url, local string) (err error)

下载文件 todo 可以增加下载进度

func HttpGetFileToDir

func HttpGetFileToDir(url, dir string, headers map[string]string) (error, string)

下载Url到指定目录

func HttpGetFileWithHeader

func HttpGetFileWithHeader(url string, headeers map[string]string, local string) error

下载文件,可以追加头

func HttpGetURL

func HttpGetURL(url string) (body string, code int, err error)

http get 请求,返回结果

func IsDirExists

func IsDirExists(path string) bool

查检目录是否存在

func IsFileExists

func IsFileExists(path string) bool

检查文件是否存在

func LoadCsvData added in v0.0.7

func LoadCsvData(source string) ([][]string, error)

读取批定的csv文件

func LoadExcel added in v0.0.7

func LoadExcel(xlsxFile string, sheet string) [][]string

读取Excel指定sheet的数据

func LoadSheet1 added in v0.0.7

func LoadSheet1(xlsxFile string) [][]string

func NumToBHex

func NumToBHex(num, n int) string

10进制数转换 n 表示进制, 16 or 36

func PostFile

func PostFile(filepath string, filename string, target_url string) (*http.Response, error)

func ReadLine added in v0.0.7

func ReadLine(fileName string, result chan<- string) error

按行读取文件 通过 chanel 返回

func ReadLineByFn added in v0.0.7

func ReadLineByFn(fileName string, cb func(s string)) error

按行读取文件 通过 chanel 返回

func Unicode2Chinese added in v0.0.7

func Unicode2Chinese(textUnquoted string) (string, error)

unicode 字符 转中文

func UssNoGenerate

func UssNoGenerate(last string) string

按 yymmdd-[A-z][0-Z] 形式生成序号

func WorkDayAdd

func WorkDayAdd(days int, startDay time.Time) time.Time

工作日计算

func Write2CsvFile added in v0.0.7

func Write2CsvFile(records [][]string, filename string) error

写入数据到指定的csv文件

func ZeroConsoleAndFileLog added in v0.0.9

func ZeroConsoleAndFileLog(filename string)

适用于命令行和日志文件都有打印

func ZeroConsoleLog

func ZeroConsoleLog()

适用于命令行输出观看

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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