gox

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: Apache-2.0 Imports: 14 Imported by: 8

README

gox

go report card

gox is a go library integrated with many useful tools.

Packages and functions

  • cache

提供对象/字节数组缓存功能

  • conn

提供连接池管理功能,以及连接自动回收。

  • consulx

  • convert

提供丰富的数据类型转换功能

  • file

提供常用的文件操作功能

  • gpip

提供一种基于tcp协议的server/client数据通讯方法。

  • httpx

    • mock实现了简单的链式http请求构造器,可以用一行代码搞定http请求。
    • upload实现了http文件上传逻辑封装处理。
  • img

基于github.com/disintegration/imaging,封装了常用的图片处理接口。

  • gifx

基于img,能够处理GIF生成,GIF加水印等操作。

  • logger

基于github.com/sirupsen/logrus, github.com/logrusorgru/aurora,能够自定义日志格式,以及输出彩色日志。

  • pluginx

  • pool

提供任务池功能,能够设置并行,等待任务数。

  • timer

简单的日期工具包

  • uuid

基于github.com/satori/go.uuid,能够生成UUID。

  • ws

基于github.com/gorilla/websocket,实现处理websocket。

Documentation

Overview

Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.

This file contains some common functions.

Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.

This file provides some functions about time operation.

Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.

This file simulate try-catch structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockTest

func BlockTest()

BlockTest blocks test methods.

func CreateTime

func CreateTime(millis int64) time.Time

CreateTime returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC. It is valid to pass nsec outside the range [0, 999999999]. Not all sec values have a corresponding time value. One such value is 1<<63-1 (the largest int64 value).

func GetDateString

func GetDateString(t time.Time) string

GetDateString gets short date format like '2018-11-11'.

func GetDay

func GetDay(t time.Time) int

GetDay gets the day of the month.

func GetHour

func GetHour(t time.Time) int

GetHour gets hour number.

func GetHumanReadableDuration

func GetHumanReadableDuration(start time.Time, end time.Time) string

GetHumanReadableDuration gets a duration between times and returns format like '01:12:31' (?hour:?minute:?second).

func GetLongDateString

func GetLongDateString(t time.Time) string

GetLongDateString gets date format like '2018-11-11 12:12:12'.

func GetLongHumanReadableDuration

func GetLongHumanReadableDuration(start time.Time, end time.Time) string

GetLongHumanReadableDuration gets a duration between times and returns format like '1d 3h 12m 11s' (?day ?hour ?minute ?second).

func GetLongLongDateString

func GetLongLongDateString(t time.Time) string

GetLongLongDateString gets short date format like '2018-11-11 12:12:12,233'.

func GetMillionSecond

func GetMillionSecond(t time.Time) int

GetMillionSecond gets millionSecond number.

func GetMinute

func GetMinute(t time.Time) int

GetMinute gets minute number.

func GetMonth

func GetMonth(t time.Time) int

GetMonth gets month number.

func GetMyAddress

func GetMyAddress(preferredNetworks ...string) string

GetPreferredIPAddress get self ip address by preferred interface

func GetNanosecond

func GetNanosecond(t time.Time) int64

GetNanosecond gets current timestamp in Nanosecond.

func GetSecond

func GetSecond(t time.Time) int

GetSecond gets second number.

func GetShortDateString

func GetShortDateString(t time.Time) string

GetShortDateString gets time format like '12:12:12'.

func GetTimestamp

func GetTimestamp(t time.Time) int64

GetTimestamp gets current timestamp in milliseconds.

func GetYear

func GetYear(t time.Time) int

GetYear gets year number.

func LimitRange

func LimitRange(value interface{}, defaultValue interface{}, rangeValues ...interface{}) interface{}

LimitRange limits a variable's value in a value range. returns defaultValue if the range not provided or the value is not in the range,

func List2Array

func List2Array(ls *list.List) []interface{}

List2Array converts list to array.

func Md5Sum

func Md5Sum(input ...string) string

Md5Sum calculates md5 value of some strings.

func ParseHostPortFromConnStr

func ParseHostPortFromConnStr(connStr string) (string, int)

ParseHostPortFromConnStr parses host and port from connection string.

func TOperation

func TOperation(condition bool, trueOperation func() interface{}, falseOperation func() interface{}) interface{}

TOperation simulates ternary operation.

func TValue

func TValue(condition bool, trueValue interface{}, falseValue interface{}) interface{}

TValue ternary operation

func Try

func Try(f func(), catcher func(e interface{}))

Try simulate try catch

func WalkList

func WalkList(ls *list.List, walker func(item interface{}) bool)

WalkList walk a list. walker return value as break signal, if it is true, break walking

Types

type IP

type IP struct {
	Address string
	Name    string
}

Directories

Path Synopsis
db
tes
hash
hashcode
see https://steveperkins.com/go-java-programmers-simple-types/
see https://steveperkins.com/go-java-programmers-simple-types/
hashmap
hashmap比golang内置的map添加速度要快,1000w数据hashmap比内置map快几百毫秒-1秒 删除速度也较快 内存占用由于hashmap实现的原因,在接近2^n但不到2^n时,hashmap占用空间较小,当hashmap扩容时(此时元素刚刚超过2^n,但是容量翻翻),hashmap会比内置map占用内存大。
hashmap比golang内置的map添加速度要快,1000w数据hashmap比内置map快几百毫秒-1秒 删除速度也较快 内存占用由于hashmap实现的原因,在接近2^n但不到2^n时,hashmap占用空间较小,当hashmap扩容时(此时元素刚刚超过2^n,但是容量翻翻),hashmap会比内置map占用内存大。
img
gifx
package gifx.
package gifx.
tes
pg
tes
set

Jump to

Keyboard shortcuts

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