goutils

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 16 Imported by: 0

README

goutils

Golang 常用工具包整理

reduce

在业务中我们可能经常会遇到某个接口需要高频的调用,例如数据库更新、插入操作,调用某api,在这里每一次的调用都会有额外的成本,所以无论是数据库还是一些api调用接口,都提供了批量操作的方式,通过批量操作来降低开销,提升效率。

位置:reduce

caseWait

Go的groutine使用起来十分的方便,可以帮助开发者快速的实现支持并行的程序,但是并行的程序往往需要根据用户的不同需求进行调度,比较常用的有sync.WaitGroup,通常是用于等待多个groutine执行完毕后继续后续的任务。

位置:caseWait

defaults

一个可以设置struct的默认值的包

位置:defaults

Documentation

Overview

* @Author: ccchieh * @Github: https://github.com/ccchieh * @Email: email@zzj.cool * @Date: 2021-04-20 19:09:02 * @LastEditors: ccchieh * @LastEditTime: 2021-04-20 19:14:19

* @Author: ccchieh * @Github: https://github.com/ccchieh * @Email: email@zzj.cool * @Date: 2021-01-18 16:10:17 * @LastEditors: ccchieh * @LastEditTime: 2021-04-13 17:15:39

* @Author: ccchieh * @Github: https://github.com/ccchieh * @Email: email@zzj.cool * @Date: 2021-01-18 16:10:17 * @LastEditors: ccchieh * @LastEditTime: 2021-05-22 19:39:06

* @Author: ccchieh * @Github: https://github.com/ccchieh * @Email: email@zzj.cool * @Date: 2021-04-07 19:58:24 * @LastEditors: ccchieh * @LastEditTime: 2021-04-07 19:58:47

* @Author: ccchieh * @Github: https://github.com/ccchieh * @Email: email@zzj.cool * @Date: 2021-01-18 16:10:17 * @LastEditors: ccchieh * @LastEditTime: 2021-05-24 18:43:43

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Encode

func Base64Encode(n int, input []byte) []byte

n is the input len

func FileIsExist

func FileIsExist(path string) bool

判断所给路径文件/文件夹是否存在

func GetWriteSyncer

func GetWriteSyncer(director string, logInConsole bool) (zapcore.WriteSyncer, error)

func HttpRequest

func HttpRequest(method string, url string, data interface{}) ([]byte, error)

func Int32Ptr

func Int32Ptr(i int32) *int32

func LegalPort

func LegalPort(port uint) bool

func LocalIp

func LocalIp() (string, error)

LocalIp 获取本地的IP

func RemoteIp

func RemoteIp(req *http.Request) string

RemoteIp 返回发起请求的远程客户端的 IP,如 192.168.1.1

func ReverseProxy

func ReverseProxy(endpoint string, rw http.ResponseWriter, req *http.Request)

ReverseProxy 用于反向代理,endpoint是代理的地址

func URLAddQuery

func URLAddQuery(addr *url.URL, key, value string)

URLAddQuery 提供一个URL,然后添加query参数

Types

This section is empty.

Directories

Path Synopsis
Package default applies default values to struct fields at their zero value.
Package default applies default values to struct fields at their zero value.
vtor 校验器
vtor 校验器

Jump to

Keyboard shortcuts

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