base

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

* @Author: lisheng * @Date: 2022-10-29 11:14:13 * @LastEditTime: 2022-12-15 15:19:02 * @LastEditors: lisheng * @Description: covert A类型 To B类型 * @FilePath: /jf-go-kit/base/convert.go

* @Author: lisheng * @Date: 2022-10-29 11:16:36 * @LastEditTime: 2022-10-29 11:16:46 * @LastEditors: lisheng * @Description: 文件创建和检测 * @FilePath: /gitee.com/liqiyuworks/jf-go-kit/base/file.go

* @Author: lisheng * @Date: 2022-10-14 23:34:41 * @LastEditTime: 2022-11-18 09:57:18 * @LastEditors: lisheng * @Description: 日志模块 * @FilePath: /gitee.com/liqiyuworks/jf-go-kit/base/log.go

* @Author: lisheng * @Date: 2022-10-29 11:42:37 * @LastEditTime: 2022-10-29 11:47:17 * @LastEditors: lisheng * @Description: 合并各种类型模块 * @FilePath: /gitee.com/liqiyuworks/jf-go-kit/base/merge.go

* @Author: lisheng * @Date: 2022-10-11 14:29:08 * @LastEditTime: 2022-11-02 23:02:33 * @LastEditors: lisheng * @Description: 通用json返回模块 * @FilePath: /gitee.com/liqiyuworks/jf-go-kit/base/response.go

* @Author: lisheng * @Date: 2022-10-29 11:20:48 * @LastEditTime: 2022-10-29 11:58:45 * @LastEditors: lisheng * @Description: 保留小数的精度 * @FilePath: /gitee.com/liqiyuworks/jf-go-kit/base/round.go

* @Author: lisheng * @Date: 2022-10-29 11:21:17 * @LastEditTime: 2022-12-23 17:30:20 * @LastEditors: lisheng * @Description: * @FilePath: /jf-go-kit/base/string.go

* @Author: lisheng * @Date: 2022-10-29 11:18:30 * @LastEditTime: 2022-12-17 16:59:09 * @LastEditors: lisheng * @Description: 时间模块 * @FilePath: /jf-go-kit/base/time.go

Index

Constants

This section is empty.

Variables

View Source
var (
	Glog = logrus.New()
)

Functions

func CheckDir

func CheckDir(dirPath string) error

func ConvertByteToString added in v0.0.17

func ConvertByteToString(bytes []byte) string

*

  • @description: ConvertByteToString
  • @param {[]byte} bytes
  • @return {*}
  • @author: liqiyuWorks

func ConvertCamelToCase

func ConvertCamelToCase(name string) string

*

  • @description: 驼峰式写法转为下划线写法
  • @param {string} name
  • @return {*}
  • @author: liqiyuWorks

func ConvertCamelToSlash added in v0.0.12

func ConvertCamelToSlash(name string) string

*

  • @description: ConvertCamelToSlash
  • @param {string} name
  • @return {*}
  • @author: liqiyuWorks

func ConvertCaseToCamel

func ConvertCaseToCamel(name string) string

*

  • @description: 下划线写法转为驼峰写法
  • @param {string} name
  • @return {*}
  • @author: liqiyuWorks

func ConvertStringToByte added in v0.0.18

func ConvertStringToByte(s string) []byte

*

  • @description: ConvertStringToByte
  • @param {string} s
  • @return {*}
  • @author: liqiyuWorks

func ConvertStructToMap

func ConvertStructToMap(i interface{}, defaultValue interface{}, ret interface{})

*

  • @description: Struct转Map
  • @param {interface{}} i
  • @param {interface{}} defaultValue: nil
  • @param {interface{}} ret
  • @return {*}
  • @author: liqiyuWorks

func ConvertToFloat64

func ConvertToFloat64(i interface{}, defaultValue float64) (ret float64)

*

  • @description: 转float64
  • @param {interface{}} i
  • @param {float64} defaultValue:0
  • @return {*}
  • @author: liqiyuWorks

func ConvertToInt

func ConvertToInt(i interface{}, defaultValue int) int

*

  • @description: 转int
  • @param {interface{}} i
  • @param {int} defaultValue: 0
  • @return {*}
  • @author: liqiyuWorks

func ConvertToInt64

func ConvertToInt64(i interface{}, defaultValue int64) (ret int64)

*

  • @description: 转int64
  • @param {interface{}} i
  • @param {int64} defaultValue:0
  • @return {*}
  • @author: liqiyuWorks

func ConvertToString

func ConvertToString(i interface{}, defaultValue string) (ret string)

*

  • @description: 转string
  • @param {interface{}} i
  • @param {string} defaultValue: ""
  • @return {*}
  • @author: liqiyuWorks

func CreateLogFile

func CreateLogFile()

func Decimal1

func Decimal1(num float64) float64

func Decimal2

func Decimal2(num float64) float64

*

  • @description: 保留float64两位小数
  • @param {float64} num
  • @return {*}
  • @author: liqiyuWorks

func GetDate

func GetDate() string

func GetDateByLocation

func GetDateByLocation(location *time.Location) string

func GetDateHour

func GetDateHour() string

func GetDateNum

func GetDateNum(location *time.Location) int

func GetDateNum2

func GetDateNum2(now *time.Time) int

func GetDayEndTimeLocal

func GetDayEndTimeLocal() time.Time

func GetDayEndTimeUtc

func GetDayEndTimeUtc() time.Time

func GetLastHourToTs

func GetLastHourToTs(ts int64) (lastHour int64)

*

  • @description: 计算最接近某小时的时间戳
  • @param {int} ts
  • @return {*}
  • @author: liqiyuWorks

func GetMonthName

func GetMonthName(location *time.Location) int

func GetMonthlyDayCount

func GetMonthlyDayCount(year int, month int) int

计算某年某月的天数

func GetNextDayStartTimeByLocation

func GetNextDayStartTimeByLocation(location *time.Location) time.Time

func GetNextDayStartTimeLocal

func GetNextDayStartTimeLocal() time.Time

func GetNextDayStartTimeUtc

func GetNextDayStartTimeUtc() time.Time

func GetSpecifiedNumToTs added in v0.0.16

func GetSpecifiedNumToTs(ts int64, hour int64) (SpecifiedHour int64)

*

  • @description: 计算最接近n个小时的时间戳, 前后匹配,找到最接近的n小时的时刻
  • @param {int64} ts
  • @param {int64} hour
  • @return {*}
  • @author: liqiyuWorks

func GetTimeByTz

func GetTimeByTz(tz string) (*time.Time, error)

func GetTimeStampMs

func GetTimeStampMs() string

func GetTimeStampSec

func GetTimeStampSec() string

func GetWeekDay

func GetWeekDay(location *time.Location) int32

func GetWeekName

func GetWeekName(location *time.Location) int

func In

func In(target string, strList []string) bool

*

  • @description: 检查一个字符串是否存在于一个数组中
  • @param {string} target
  • @param {[]string} strList
  • @return {*}
  • @author: liqiyuWorks

func InitLogger

func InitLogger()

func Lcfirst

func Lcfirst(str string) string

*

  • @description: 首字母小写
  • @param {string} str
  • @return {*}
  • @author: liqiyuWorks

func MergeMaps

func MergeMaps(mObj ...map[string]interface{}) map[string]interface{}

*

  • @description: 合并maps
  • @param {...map[string]interface{}} mObj
  • @return {*}
  • @author: liqiyuWorks

func MergeStrings

func MergeStrings(strs ...string) string

*

  • @description: 合并字符串
  • @param {...string} strs
  • @return {*}
  • @author: liqiyuWorks

func MkDir

func MkDir(dirPath string) error

func PathExist

func PathExist(path string) error

func PrintPerformTimeConsuming

func PrintPerformTimeConsuming(funcName string, startTime time.Time)

func StringSub

func StringSub(str string, n int, reverse bool) string

*

  • @description: 截取字符串
  • @param {string} str
  • @param {int} n
  • @param {bool} reverse: true: 反向切片, false: 正向切片
  • @return {*}
  • @author: liqiyuWorks

func StringSubA2B added in v0.0.22

func StringSubA2B(str string, a int, b int, reverse bool) string

*

  • @description: StringSubA2B
  • @param {string} str
  • @param {int} a
  • @param {int} b
  • @param {bool} reverse fasle:正序 true 逆序
  • @return {*}
  • @author: liqiyuWorks

func TimeName

func TimeName(t time.Time) string

func Ucfirst

func Ucfirst(str string) string

*

  • @description: 首字母大写
  • @return {*}
  • @author: liqiyuWorks

Types

type BaseResponse

type BaseResponse struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg,omitempty"`
	Data interface{} `json:"data"`
}

type Buffer

type Buffer struct {
	*bytes.Buffer
}

内嵌bytes.Buffer,支持连写

func NewBuffer

func NewBuffer() *Buffer

func (*Buffer) Append

func (b *Buffer) Append(i interface{}) *Buffer

Jump to

Keyboard shortcuts

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