tools

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: MIT Imports: 16 Imported by: 0

README

类: Pagination: 分页工具 JSONMarshalString: Marshal JSON

Documentation

Overview

Package tools Copyright 2016-2023 chad.wang<chad.wang@icloudsky.com>. All rights reserved.

Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.

Package tools Copyright 2016-2023 chad.wang<chad.wang@icloudsky.com>. All rights reserved.

Package tools Copyright 2016-2023 chad.wang<chad.wang@icloudsky.com>. All rights reserved.

Package tools Copyright 2016-2023 chad.wang<chad.wang@icloudsky.com>. All rights reserved.

Package tools Copyright 2016-2023 chad.wang<chad.wang@icloudsky.com>. All rights reserved.

Package tools Copyright 2016-2023 chad.wang<chad.wang@icloudsky.com>. All rights reserved.

Index

Constants

View Source
const (
	RandomLowercase type_ = 1 // 小写字母
	RandomMajuscule       = 2 // 大写字母
	RandomNumber          = 4 // 数字
	RandomSymbol          = 8 // 符号
	RandomAll             = RandomLowercase | RandomMajuscule | RandomNumber | RandomSymbol
)
View Source
const TimeFormatString = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

func Close added in v0.0.2

func Close(f io.Closer)

Close 快捷关闭

func FormatTime

func FormatTime(i int64) string

FormatTime 将时间缀格式为YYYY-MM-DD HH:mm:ss

func GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory 返回工作目录

func IsAndroid

func IsAndroid() bool

IsAndroid 判断是否linux系统

func IsDarwin

func IsDarwin() bool

IsDarwin 判断是不是Mac

func IsLinux

func IsLinux() bool

IsLinux 判断是否linux系统

func IsNumber

func IsNumber(s string) bool

IsNumber 判断一个字符串是不是全都是数字

func IsWindows

func IsWindows() bool

IsWindows 判断是不是windows

func JSONMarshalByte

func JSONMarshalByte(v interface{}) []byte

JSONMarshalByte 忽略错误,返回JSON.Marshal后的[]byte

func JSONMarshalString

func JSONMarshalString(v interface{}) string

JSONMarshalString 忽略错误,返回JSON.Marshal后的string

func Md5

func Md5(s string) string

Md5 计算md5值

func Md5File

func Md5File(filePath string) (string, error)

Md5File 计算文件md5

func PathExists

func PathExists(path string) (bool, error)

PathExists 判断目录或者文件是否存在

func RandomStr

func RandomStr(length uint, contain type_) string

RandomStr 随机字符串

func RemoveSameFromStringSlice

func RemoveSameFromStringSlice(slice []string) []string

RemoveSameFromStringSlice 移除 []string 中的相同元素

func ReverseByte

func ReverseByte(s []byte) []byte

ReverseByte 反转字节

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 客户端

func NewClient

func NewClient() *Client

NewClient 创建新 Client

func (*Client) Get

func (c *Client) Get(url string) ([]byte, error)

Get 发送GET请求

func (*Client) Post

func (c *Client) Post(url string, requestBody string) ([]byte, error)

Post 发送POST请求

func (*Client) SetCert

func (c *Client) SetCert(crt, key, ca []byte) (err error)

SetCert 设置证书

func (*Client) SetHeader

func (c *Client) SetHeader(key string, value string)

SetHeader 设置header

func (*Client) SetTimeout

func (c *Client) SetTimeout(duration time.Duration)

SetTimeout 设置超时时间

type PaginationData

type PaginationData struct {
	Total        int64   // 总记录数
	Page         int64   // 第几页
	PageSize     int64   // 每页显示多少条记录
	PageNums     int64   // 显示多少个数字
	FirstPage    int64   // 第一页
	LastPage     int64   // 最后一页
	PreviousPage int64   // 上一页,没有上一页时为 0
	NextPage     int64   // 下一页,没有下一页时为 0
	TotalPage    int64   // 总页数
	Pages        []int64 // 分页页码
}

PaginationData 分页结果数据

func Pagination

func Pagination(total, page, pageSize int64, pageNum int64) (pg *PaginationData)

Pagination 分页组件 count 记录总数 page 当前页, 如果小于1会修正为1 pageSize 每一页显示量,如果小于1会修正为1 pagesNum 分页时中间显示多少个数字,如果小于1,会修正为1

Jump to

Keyboard shortcuts

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