lib/

directory
v0.0.0-...-75a017b Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT

README

lib

基础能力

  • cast 类型转换
  • mapstructure 将map解码为结构体
  • mergo 合并同类型结构体、map
  • sprig 模板函数
  • filenamify Convert a string to a valid safe filename
  • fsnotify 文件系统通知
  • jitterbug Tickers with random jitter
  • cron 定时执行
  • pflag 命令行
  • cobra 命令行
  • shortid id生成器
  • sonyflake id生成器
  • uuid id生成器
  • godotenv 从文件加载环境变量
  • env 将环境变量加载到结构体
  • viper 配置管理
  • glog 日志
  • logrus 日志
  • zap 日志
  • lo Iterate over slices, maps, channels...
  • decimal 小数四舍五入

数据处理

  • charts 生成统计图
  • gofakeit 数据生成
  • govalidator 数据验证
  • gocsv csv处理
  • protobuf protobuf处理
  • yaml yaml处理
  • toml toml处理
  • goquery html处理
  • excelize excel处理
  • exl excel处理
  • fastjson json处理
  • json json处理 兼容标准库 好像比 jsoniter 快
  • jsoniter json处理 兼容标准库

客户端

  • ali 阿里云

  • aws Amazon Web Services

  • ip2locationio IP2Location

  • k8s k8s客户端

  • otel otel客户端

  • prometheus prometheus客户端

  • nsq nsq客户端

  • sarama kafka客户端

  • temporal temporal客户端

  • gorm 数据库orm

  • mysql mysql驱动

  • redis redis客户端

  • redsync redis分布式锁

框架

  • imap imap库
  • resty http请求库
  • req http请求库
  • swag http文档生成器
  • gin http服务框架
  • grpc rpc框架
  • zero http服务和rpc框架
  • casbin 权限控制框架
  • jwt jwt框架
  • ratelimit 访问次数限制
  • i18n 国际化
  • ws websocket
  • wsg websocket
  • wsn websocket
  • otto javascript解释器

Directories

Path Synopsis
ali
api
captcha
交互流程 https://help.aliyun.com/zh/captcha/captcha2-0/product-overview/what-is-alibaba-cloud-captcha-2 接入流程 https://help.aliyun.com/zh/captcha/captcha2-0/user-guide/access-guidelines
交互流程 https://help.aliyun.com/zh/captcha/captcha2-0/product-overview/what-is-alibaba-cloud-captcha-2 接入流程 https://help.aliyun.com/zh/captcha/captcha2-0/user-guide/access-guidelines
oss
权限控制 https://help.aliyun.com/zh/oss/developer-reference/access-control-1/
权限控制 https://help.aliyun.com/zh/oss/developer-reference/access-control-1/
ram
访问控制 https://help.aliyun.com/zh/ram/ https://help.aliyun.com/zh/ram/developer-reference/sts-sdk-overview
访问控制 https://help.aliyun.com/zh/ram/ https://help.aliyun.com/zh/ram/developer-reference/sts-sdk-overview
aws
https://docs.aws.amazon.com/sdk-for-go/ https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2
https://docs.aws.amazon.com/sdk-for-go/ https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2
s3
https://aws.amazon.com/cn/s3/ https://docs.aws.amazon.com/s3/
https://aws.amazon.com/cn/s3/ https://docs.aws.amazon.com/s3/
https://github.com/spf13/cobra/blob/main/site/content/user_guide.md Commands represent actions, Args are things and Flags are modifiers for those actions.
https://github.com/spf13/cobra/blob/main/site/content/user_guide.md Commands represent actions, Args are things and Flags are modifiers for those actions.
定时调度器,必须先调用Init()初始化
定时调度器,必须先调用Init()初始化
excel结构体绑定
excel结构体绑定
无需声明,直接获取json字段值 fastjson parses the input JSON only once.
无需声明,直接获取json字段值 fastjson parses the input JSON only once.
gin
https://github.com/gin-gonic/gin/blob/master/docs/doc.md https://gin-gonic.com/docs/examples/ https://github.com/gin-gonic/examples
https://github.com/gin-gonic/gin/blob/master/docs/doc.md https://gin-gonic.com/docs/examples/ https://github.com/gin-gonic/examples
examples/docs
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
flag.Parse must be called before any logging is done.
flag.Parse must be called before any logging is done.
随机生成
随机生成
使用css选择器
使用css选择器
插入操作 https://gorm.io/docs/create.html
插入操作 https://gorm.io/docs/create.html
logger
开放gorm.io/gorm/logger包的logger
开放gorm.io/gorm/logger包的logger
https://grpc.io/ https://grpc.io/docs/languages/go/ https://github.com/grpc/grpc-go/tree/master/Documentation https://github.com/grpc/grpc-go/tree/master/examples
https://grpc.io/ https://grpc.io/docs/languages/go/ https://github.com/grpc/grpc-go/tree/master/Documentation https://github.com/grpc/grpc-go/tree/master/examples
https://ip2location-io-go.readthedocs.io/en/latest/
https://ip2location-io-go.readthedocs.io/en/latest/
Fast JSON encoder/decoder compatible with encoding/json for Go
Fast JSON encoder/decoder compatible with encoding/json for Go
100% compatibility with standard lib
100% compatibility with standard lib
https://golang-jwt.github.io/jwt/ 内部使用 base64.RawURLEncoding.EncodeToString,没有padding
https://golang-jwt.github.io/jwt/ 内部使用 base64.RawURLEncoding.EncodeToString,没有padding
k8s
k8s客户端,必须先初始化 NewForFile 集群外客户端初始化 NewInCluster 集群内客户端初始化 https://github.com/kubernetes/client-go/blob/master/INSTALL.md https://github.com/kubernetes/client-go/tree/master/examples
k8s客户端,必须先初始化 NewForFile 集群外客户端初始化 NewInCluster 集群内客户端初始化 https://github.com/kubernetes/client-go/blob/master/INSTALL.md https://github.com/kubernetes/client-go/tree/master/examples
examples
集群内客户端 https://github.com/kubernetes/client-go/tree/master/examples/in-cluster-client-configuration
集群内客户端 https://github.com/kubernetes/client-go/tree/master/examples/in-cluster-client-configuration
当json解码到any接口时,接口实际类型对应关系 map[string]interface{}, for JSON objects https://pkg.go.dev/encoding/json#Unmarshal
当json解码到any接口时,接口实际类型对应关系 map[string]interface{}, for JSON objects https://pkg.go.dev/encoding/json#Unmarshal
示例 https://github.com/nsqio/nsq/tree/master/apps
示例 https://github.com/nsqio/nsq/tree/master/apps
参考SigNoz文档 https://signoz.io/docs/instrumentation/golang/
参考SigNoz文档 https://signoz.io/docs/instrumentation/golang/
https://prometheus.io/docs/guides/go-application/ https://github.com/prometheus/client_golang/tree/main/examples
https://prometheus.io/docs/guides/go-application/ https://github.com/prometheus/client_golang/tree/main/examples
https://redis.uptrace.dev/guide/ 封装 redis 客户端,基于命令封装第三方库 必须先调用 Init 进行初始化
https://redis.uptrace.dev/guide/ 封装 redis 客户端,基于命令封装第三方库 必须先调用 Init 进行初始化
Redis-based distributed mutual exclusion lock https://redis.io/docs/manual/patterns/distributed-locks/
Redis-based distributed mutual exclusion lock https://redis.io/docs/manual/patterns/distributed-locks/
https://req.cool/
https://req.cool/
非200响应码会正常返回响应,不会返回错误
非200响应码会正常返回响应,不会返回错误
https://github.com/Shopify/sarama/tree/main/examples/sasl_scram_client
https://github.com/Shopify/sarama/tree/main/examples/sasl_scram_client
sonyflake 分布式唯一id生成器 必须先调用 Init 初始化
sonyflake 分布式唯一id生成器 必须先调用 Init 初始化
模板函数列表 https://masterminds.github.io/sprig/
模板函数列表 https://masterminds.github.io/sprig/
https://github.com/swaggo/swag go install github.com/swaggo/swag/cmd/swag@latest swag init swaggertype 结构体标签 swaggerignore 结构体标签
https://github.com/swaggo/swag go install github.com/swaggo/swag/cmd/swag@latest swag init swaggertype 结构体标签 swaggerignore 结构体标签
封装 temporal 客户端 必须先调用 Init 初始化客户端,才能调用其它函数
封装 temporal 客户端 必须先调用 Init 初始化客户端,才能调用其它函数
json toml 互转 go install github.com/pelletier/go-toml/v2/cmd/tomljson@latest go install github.com/pelletier/go-toml/v2/cmd/jsontoml@latest
json toml 互转 go install github.com/pelletier/go-toml/v2/cmd/tomljson@latest go install github.com/pelletier/go-toml/v2/cmd/jsontoml@latest
ws
websocket https://www.rfc-editor.org/rfc/rfc6455 https://github.com/gobwas/ws-examples
websocket https://www.rfc-editor.org/rfc/rfc6455 https://github.com/gobwas/ws-examples
wsg
Connections support one concurrent reader and one concurrent writer.
Connections support one concurrent reader and one concurrent writer.
https://github.com/nhooyr/websocket/tree/master/examples
https://github.com/nhooyr/websocket/tree/master/examples
zap好像比logrus块 zap必须要初始化
zap好像比logrus块 zap必须要初始化
配置 直接从环境变量读取 `json:",env=SERVICE_NAME"` 或者配置yaml文件 ${SERVICE_NAME}
配置 直接从环境变量读取 `json:",env=SERVICE_NAME"` 或者配置yaml文件 ${SERVICE_NAME}

Jump to

Keyboard shortcuts

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