util

package module
v0.0.0-...-7f2d1a5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 20 Imported by: 0

README

simpleutil-go

介绍

{以下是 Gitee 平台说明,您可以替换此简介 Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 https://gitee.com/enterprises}

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const DefaultTimeFormat = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

func Assert

func Assert(b bool, text string)

func Assertf

func Assertf(b bool, format string, args ...any)

func CopyBytes

func CopyBytes(src []byte) (dst []byte)

func DeserializeFromStringArray

func DeserializeFromStringArray(i any, stringArray []string) (err error)

func DeserializeStructFromExcelRow

func DeserializeStructFromExcelRow(e any, row *xlsx.Row) (err error)

func Format

func Format(format string, args ...any) string

func FormatFieldName

func FormatFieldName(rawName string) string

格式化字段名, 比如: xlsx表字段, mysql表字段

func GetBuffer

func GetBuffer() *bytes.Buffer

func GetDurationToNextHalfHour

func GetDurationToNextHalfHour() time.Duration

GetDurationToNextHalfHour 获取下个整点或半小时到当前的时差

func GetDurationToNextMinute

func GetDurationToNextMinute() time.Duration

GetDurationToNextMinute 获取当前和下一分钟的时差

func GetFileBaseName

func GetFileBaseName(file string) string

GetFileBaseName 获取路径中的文件名,不含扩展名

func GetFileName

func GetFileName(file string) string

GetFileName 获取路径中的文件名

func GetNextHalfHour

func GetNextHalfHour() time.Time

GetNextHalfHour 获取整点和半小时 例如: 当前是19:20, 则获取到的是19:30, 如果是19:40, 获取到的是20:00

func GetNextMinute

func GetNextMinute() time.Time

GetNextMinute 获取下一分钟时间戳

func GetNextSecond

func GetNextSecond() time.Time

GetNextSecond 获取下一秒钟时间戳

func GetProgramFileAbsPath

func GetProgramFileAbsPath() (string, error)

GetProgramFileAbsPath 获取当前可执行文件绝对路径

func GetProgramFileBaseName

func GetProgramFileBaseName() (string, error)

GetProgramFileBaseName 获取当前可执行文件名(不含扩展名)

func GetProgramFileName

func GetProgramFileName() (string, error)

GetProgramFileName 获取当前可执行文件名(含扩展名)

func GetTheDayBeginTime

func GetTheDayBeginTime(src time.Time, days int) (desc time.Time)

GetTheDayBeginTime 获取距离某时刻n天的开始时刻

func GetTheWeekBeginTime

func GetTheWeekBeginTime(src time.Time) (desc time.Time)

GetTheWeekBeginTime 获取某周周一0点0分0秒时刻

func GetThisMinute

func GetThisMinute() time.Time

GetThisMinute 获取这一分钟时间戳

func GetThisSecond

func GetThisSecond() time.Time

GetThisSecond 获取这一秒钟时间戳

func GetTypeName

func GetTypeName(i any) string

GetTypeName 获取接口中存放的实例的类型名

func IsDirOrFileExist

func IsDirOrFileExist(path string) error

IsDirOrFileExist 如果目录不存在创建指定目录

func IsSameDay

func IsSameDay(t1 time.Time, t2 time.Time) bool

func IsSameDayUnixTimeStamp

func IsSameDayUnixTimeStamp(t1 int64, t2 int64) bool

IsSameDayUnixTimeStamp 判断2个unix时间戳是不是同一天

func LoadJSONFile

func LoadJSONFile(file string, dst any) error

LoadJSONFile 加载JSON文件

func LowerFirst

func LowerFirst(str string) string

func MD5Sum

func MD5Sum(input []byte) (output []byte)

生成md串

func MD5Sumf

func MD5Sumf(format string, args ...any) (output []byte)

生成md串

func MakeSignalChannel

func MakeSignalChannel(sig ...os.Signal) chan os.Signal

func MkDir

func MkDir(path string) error

MkDir 如果目录不存在创建指定目录

func MustGetProgramFileAbsPath

func MustGetProgramFileAbsPath() string

MustGetProgramFileAbsPath 获取当前可执行文件绝对路径

func MustGetProgramFileBaseName

func MustGetProgramFileBaseName() string

MustGetProgramFileBaseName 获取当前可执行文件名(不含扩展名)

func MustGetProgramFileName

func MustGetProgramFileName() string

MustGetProgramFileName 获取当前可执行文件名(含扩展名)

func MustMkDir

func MustMkDir(path string)

MustMkDir 如果目录不存在创建指定目录

func ParseTimeString

func ParseTimeString(strTime string) (time.Time, error)

func ParseTimeStringByFormat

func ParseTimeStringByFormat(fmt string, strTime string) (time.Time, error)

ParseTimeStringByFormat 解析时间字符串, 返回UTC时间

func ParseTimeStringInLocation

func ParseTimeStringInLocation(strTime string) (time.Time, error)

func ParseTimeStringInLocationByFormat

func ParseTimeStringInLocationByFormat(fmt string, strTime string) (time.Time, error)

ParseTimeStringInLocationByFormat 解析时间字符串, 返回本地时间

func PutBuffer

func PutBuffer(b *bytes.Buffer)

func ReadLineFromConsole

func ReadLineFromConsole() (string, error)

func TruncateExtend

func TruncateExtend(file string) string

TruncateExtend 去掉文件扩展名

func UpperFirst

func UpperFirst(str string) string

func WaitExitSignal

func WaitExitSignal() os.Signal

func Walk

func Walk(dir string, extend string, whiteList []string, blackList []string, fn func(path string, info os.FileInfo, name string, isInBlackList bool) (continued bool)) (err error)

Walk 遍历目录

func Zip

func Zip(src []string, dest string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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