搜集平时看到的go语言的开源库,方便以后开发使用。

GUI

gowid github

gocui github

termui github

termdash github

color github 直接用color输出,替代fmt

aurora github 嵌入到fmt中只给指定的内容改色

bar github

spinner github

go-prompt github

survey github

climenu github

uitable github

render the data

NAME          BIRTHDAY          BIO
Ada Lovelace  December 10, 1815 Ada was a British mathematician and writer, chi...
Alan Turing   June 23, 1912     Alan was a British pioneering computer scientis...

系统架构

web

gin github

ginpprof github A wrapper for gin to use net/http/pprof easily.

ginprom github Gin Prometheus metrics exporter

身份验证系统

authboss github

微服务

go-kit 文档 github

go-micro 文档 github

go-chassis 文档 github

graceful github master worker模式启动http服务,无缝热重启和更新。

微服务调试

squash github

OAuth2

hydra github

go-oauth2-server github

go-oauth2 github

HTTP和REST请求的客户端

resty github

JSON解析

json-iterator github doc

API 网关

goku-api-gateway github 悟空API网关 开源版

权限管理

casbin github ACL, RBAC, ABAC in Golang

permissions2 github login states and permissions supports gin

UUID

wuid github

通知管理

goalert github

Session

session github

ORM

gorm github doc

xorm github

类型转换

cast github

validator

govalidator github

package main

import (
	"encoding/json"
	"fmt"
	"net/http"

	"github.com/thedevsaddam/govalidator"
)

func handler(w http.ResponseWriter, r *http.Request) {
	rules := govalidator.MapData{
		"username": []string{"required", "between:3,8"},
		"email":    []string{"required", "min:4", "max:20", "email"},
		"web":      []string{"url"},
		"phone":    []string{"digits:11"},
		"agree":    []string{"bool"},
		"dob":      []string{"date"},
	}

	messages := govalidator.MapData{
		"username": []string{"required:আপনাকে অবশ্যই ইউজারনেম দিতে হবে", "between:ইউজারনেম অবশ্যই ৩-৮ অক্ষর হতে হবে"},
		"phone":    []string{"digits:ফোন নাম্বার অবশ্যই ১১ নম্বারের হতে হবে"},
	}

	opts := govalidator.Options{
		Request:         r,        // request object
		Rules:           rules,    // rules map
		Messages:        messages, // custom message map (Optional)
		RequiredDefault: true,     // all the field to be pass the rules
	}
	v := govalidator.New(opts)
	e := v.Validate()
	err := map[string]interface{}{"validationError": e}
	w.Header().Set("Content-type", "application/json")
	json.NewEncoder(w).Encode(err)
}

func main() {
	http.HandleFunc("/", handler)
	fmt.Println("Listening on port: 9000")
	http.ListenAndServe(":9000", nil)
}

govalidator github

func Abs(value float64) float64
func BlackList(str, chars string) string
func ByteLength(str string, params ...string) bool
func CamelCaseToUnderscore(str string) string
func Contains(str, substring string) bool
func Count(array []interface{}, iterator ConditionIterator) int
func Each(array []interface{}, iterator Iterator)
func ErrorByField(e error, field string) string
func ErrorsByField(e error) map[string]string
func Filter(array []interface{}, iterator ConditionIterator) []interface{}
func Find(array []interface{}, iterator ConditionIterator) interface{}
func GetLine(s string, index int) (string, error)
func GetLines(s string) []string
func InRange(value, left, right float64) bool
func IsASCII(str string) bool
func IsAlpha(str string) bool
func IsAlphanumeric(str string) bool
func IsBase64(str string) bool
func IsByteLength(str string, min, max int) bool
func IsCIDR(str string) bool
func IsCreditCard(str string) bool
func IsDNSName(str string) bool
func IsDataURI(str string) bool
func IsDialString(str string) bool
func IsDivisibleBy(str, num string) bool
func IsEmail(str string) bool
func IsFilePath(str string) (bool, int)
func IsFloat(str string) bool
func IsFullWidth(str string) bool
func IsHalfWidth(str string) bool
func IsHexadecimal(str string) bool
func IsHexcolor(str string) bool
func IsHost(str string) bool
func IsIP(str string) bool
func IsIPv4(str string) bool
func IsIPv6(str string) bool
func IsISBN(str string, version int) bool
func IsISBN10(str string) bool
func IsISBN13(str string) bool
func IsISO3166Alpha2(str string) bool
func IsISO3166Alpha3(str string) bool
func IsISO693Alpha2(str string) bool
func IsISO693Alpha3b(str string) bool
func IsISO4217(str string) bool
func IsIn(str string, params ...string) bool
func IsInt(str string) bool
func IsJSON(str string) bool
func IsLatitude(str string) bool
func IsLongitude(str string) bool
func IsLowerCase(str string) bool
func IsMAC(str string) bool
func IsMongoID(str string) bool
func IsMultibyte(str string) bool
func IsNatural(value float64) bool
func IsNegative(value float64) bool
func IsNonNegative(value float64) bool
func IsNonPositive(value float64) bool
func IsNull(str string) bool
func IsNumeric(str string) bool
func IsPort(str string) bool
func IsPositive(value float64) bool
func IsPrintableASCII(str string) bool
func IsRFC3339(str string) bool
func IsRFC3339WithoutZone(str string) bool
func IsRGBcolor(str string) bool
func IsRequestURI(rawurl string) bool
func IsRequestURL(rawurl string) bool
func IsSSN(str string) bool
func IsSemver(str string) bool
func IsTime(str string, format string) bool
func IsURL(str string) bool
func IsUTFDigit(str string) bool
func IsUTFLetter(str string) bool
func IsUTFLetterNumeric(str string) bool
func IsUTFNumeric(str string) bool
func IsUUID(str string) bool
func IsUUIDv3(str string) bool
func IsUUIDv4(str string) bool
func IsUUIDv5(str string) bool
func IsUpperCase(str string) bool
func IsVariableWidth(str string) bool
func IsWhole(value float64) bool
func LeftTrim(str, chars string) string
func Map(array []interface{}, iterator ResultIterator) []interface{}
func Matches(str, pattern string) bool
func NormalizeEmail(str string) (string, error)
func PadBoth(str string, padStr string, padLen int) string
func PadLeft(str string, padStr string, padLen int) string
func PadRight(str string, padStr string, padLen int) string
func Range(str string, params ...string) bool
func RemoveTags(s string) string
func ReplacePattern(str, pattern, replace string) string
func Reverse(s string) string
func RightTrim(str, chars string) string
func RuneLength(str string, params ...string) bool
func SafeFileName(str string) string
func SetFieldsRequiredByDefault(value bool)
func Sign(value float64) float64
func StringLength(str string, params ...string) bool
func StringMatches(s string, params ...string) bool
func StripLow(str string, keepNewLines bool) string
func ToBoolean(str string) (bool, error)
func ToFloat(str string) (float64, error)
func ToInt(str string) (int64, error)
func ToJSON(obj interface{}) (string, error)
func ToString(obj interface{}) string
func Trim(str, chars string) string
func Truncate(str string, length int, ending string) string
func UnderscoreToCamelCase(s string) string
func ValidateStruct(s interface{}) (bool, error)
func WhiteList(str, chars string) string
type ConditionIterator
type CustomTypeValidator
type Error
func (e Error) Error() string
type Errors
func (es Errors) Error() string
func (es Errors) Errors() []error
type ISO3166Entry
type Iterator
type ParamValidator
type ResultIterator
type UnsupportedTypeError
func (e *UnsupportedTypeError) Error() string
type Validator

Porform 性能

ginpprof github

消息队列

nats-server github  nats.go github  doc

DB

mongo-go-driver github

mongo-go-examples github

CI

drone github

运维发布

gopub github 已停更

go-git-webhook github

multissh github ssh轮子

teaweb github doc

进程管理

supervisord github

Docker 容器测试

container-structure-test github

PDF 读写

gofpdf github

go-wkhtmltopdf github html转pdf

pdfcpu github PDF文件加工处理

Excel读写

excelize github

图像生成

canvas github

多语言

getlang github

example:

package main

import (
	"fmt"
	"github.com/rylans/getlang"
)

func main(){
  info := getlang.FromString("Wszyscy ludzie rodzą się wolni i równi w swojej godności i prawach")
  fmt.Println(info.LanguageCode(), info.Confidence())
}

分词

gse github

package main

import (
	"flag"
	"fmt"
	"log"

	"github.com/go-ego/gse"
)

var (
	text = flag.String("text", "《复仇者联盟3:无限战争》是全片使用IMAX摄影机拍摄", "要分词的文本")
)

func main() {
	flag.Parse()

	var seg gse.Segmenter
	// seg.LoadDict("../data/dict/dictionary.txt")
	// 加载默认词典
	seg.LoadDict()

	segments := seg.Segment([]byte(*text))
	fmt.Println(gse.ToString(segments, true))

	text2 := []byte("深圳地标建筑, 深圳地王大厦")
	fmt.Println(seg.String(text2, true))
	fmt.Println(seg.Slice(text2, true))

	segs := seg.Segment(text2)

	// log.Println(gse.ToString(segs, false))
	log.Println(gse.ToString(segs))
	// 深圳/ns 地标/n 建筑/n ,/x  /x 深圳/ns 地王大厦/n

	// 搜索模式主要用于给搜索引擎提供尽可能多的关键字
	// segs := seg.ModeSegment(text2, true)
	log.Println("搜索模式: ", gse.ToString(segs, true))
	// 搜索模式: 深圳/ns 地标/n 建筑/n ,/x  /x 深圳/ns 地王/n 大厦/n 地王大厦/n
}

kagome github

cli 命令集成

cobra github

图像处理

image2ascii github

imgproxy github

静态资源打包进程序

fileb0x github 比statik定制性高

statik github

日志 Log

zerolog github 利用context时比zap快

zap github

logger, _ := zap.NewProduction()
defer logger.Sync() // flushes buffer, if any
sugar := logger.Sugar()
sugar.Infow("failed to fetch URL",
  // Structured context as loosely typed key-value pairs.
  "url", url,
  "attempt", 3,
  "backoff", time.Second,
)
sugar.Infof("Failed to fetch URL: %s", url)

Loki: like Prometheus, but for logs. github

KeyValue Storage

bbolt github

godown github

OpenCV

gocv github

文件下载

massivedl github

grab github

go-getter github hashicorp

邮件处理

go-imap github

hermes github generates clean, responsive HTML e-mails

读取配置文件

viper github

2FA 双因素认证

otp github

测试

BDD

ginkgo github gomega github

mock

mockery github

模拟文件系统

afero github

断言

testify github

Compile-time Dependency Injection

wire github sample

代码质量分析

goreporter github

goreporter -p [projectRelativePath] -r [reportPath] -e [exceptPackagesName] -f [json/html/text]  {-t templatePathIfHtml}

软件许可证检查

license-check github

字符串处理

go-strutil github

Cron 定时器

scheduler github

cron github

chart 图表

go-echarts github

私有云平台

pritunl-cloud github

crossplane github 多云监控平台

AWS SDK

aws-sdk-go github doc

交互式命令执行

go-pry github 可以参考其实现动态提示的方法

GPIO

go-rpio github

SAKS-SDK-GO github

浏览器控制

chromedp github (headless chrome)

====== 以下为 shell ======

kjyw gitee 运维脚本工具库

====== 以下为 APP ======

SSH 隧道

mole github

加密笔记应用(利用bbolt存储)

offlinenotepad github

命令行密码管理工具

pwsafe github

可配置的命令行Dashboard工具

sampler github

Lint检查工具

golangci-lint github

mod 依赖分析工具

gomod github

远程调试工具

webrtc-remote-screen github

安全检查

huskyCI github CI/CD过程中的安全检查

====== 以下为其他网址 ======

awesome-go

athens : go proxy 服务加速 github