该限流器是基于Token

分享到:

x

[TOC] awesome-go

x

golang.org/x/time/rate 该限流器是基于Token Bucket(令牌桶)实现的。

goweight 分析模块大小

1$ cd current-project
2$ goweight

godebug:一个跨平台的Go程序调试工具

https://github.com/mailgun/godebug 已过时

NEW https://github.com/derekparker/delve

yaegi go解释器

https://github.com/containous/yaegi 可以提供交互环境

https://github.com/topxeq/gotx

热更新

https://github.com/cosmtrek/air

https://github.com/topics/live-reload?l=go

gops 分析机器上运行了哪些go进程

go get -u github.com/google/gops

 1C:\Users\35084>gops tree
 2...
 3├── 16712
 4│   └── 5988 (gops.exe) {go1.14.1}
 5├── 4728
 6│   ├── 16028 (com.docker.backend.exe) {go1.12.16}
 7│   └── 3708 (com.docker.proxy.exe) {go1.12.16}
 8└── 5172
 9    └── 12080 (gopls.exe) {go1.14.1}
10
11
12C:\Users\35084>gops
1318256 16712 gops.exe                go1.14.1  D:\go\bin\gops.exe
1416028 4728  com.docker.backend.exe  go1.12.16 C:\Program Files\Docker\Docker\resources\com.docker.backend.exe
1512080 5172  gopls.exe               go1.14.1  D:\go\bin\gopls.exe
163708  4728  com.docker.proxy.exe    go1.12.16 C:\Program Files\Docker\Docker\resources\com.docker.proxy.exe
17
18C:\Users\35084>gops 3708
19parent PID:     4728
20threads:        12
21memory usage:   0.058%
22cpu usage:      0.001%
23username:       DESKTOP-PK520IC\35084
24cmd+args:       "com.docker.proxy.exe"  -dockerExe "C:\Program Files\Docker\Docker\resources\bin\docker.exe"  -host-names host.docker.internal,docker.for.win.host.internal,docker.for.win.localhost -gateway-names gateway.docker.internal,docker.for.win.gateway.internal,docker.for.win.http.internal -vm-names vm.docker.internal,docker-for-desktop,docker-desktop,kubernetes.docker.internal -host-ip 192.168.65.2 -gateway-ip 192.168.65.1 -vm-ip 192.168.65.3 -pki "C:\ProgramData\DockerDesktop\pki" -inject-hosts=True
25elapsed time:   02:45:26
26local/remote:   127.0.0.1:33499 <-> 0.0.0.0:0 (LISTEN)
27local/remote:   127.0.0.1:53974 <-> :0 ()

json

github.com/liamylian/json-hashids

序列化自动加密

orm

facebook开源的新的go语言orm模块,An entity framework for Go Simple, yet powerful ORM for modeling and querying data. https://github.com/facebookincubator/ent

DI

Google wire 3.3k

https://github.com/google/wire

Wire 可以生成 Go 源码并在编译期完成依赖注入。它不需要反射机制或 Service Locators

好处:

  1. 方便 debug,若有依赖缺失编译时会报错
  2. 因为不需要 Service Locators, 所以对命名没有特殊要求
  3. 避免依赖膨胀。生成的代码只包含被依赖的代码,而运行时依赖注入则无法作到这一点
  4. 依赖关系静态存于源码之中, 便于工具分析与可视化

Compile-time Dependency Injection With Go Cloud's Wire

一文读懂 Go官方的 Wire

Uber dig 1.3k

运行时依赖注入 https://github.com/uber-go/dig

Facebook inject 1.2k(归档了,不更新)

运行时依赖注入 https://github.com/facebookarchive/inject

spinal-case(脊柱) or snake_case(蛇形) or CamelCase(驼峰式) or KebabCase(短横线) or PascalCase(帕斯卡命名法) or PascalSnakeCase

https://github.com/iancoleman/strcase

GUI

Cross platform GUI in Go based on Material Design https://fyne.io/ https://github.com/fyne-io/fyne

请注意,默认情况下,Windows应用程序是从命令提示符加载的,这意味着,如果单击图标,则可能会看到命令窗口。 要解决此问题,请在运行或构建命令中添加参数-ldflags -H = windowsgui。

Prerequisites https://fyne.io/develop/ Windows

  1. Download Go from the download page and follow instructions
  2. Install one of the available C compilers for windows, the following are tested with Go and Fyne:
    • MSYS2 with MingW-w64 - msys2.org
    • TDM-GCC - tdm-gcc.tdragon.net
    • Cygwin - cygwin.com
  3. In Windows your graphics driver will already be installed, but it is recommended to ensure they are up to date.

eval

github.com/Knetic/govaluate

限流熔断

https://github.com/alibaba/sentinel-golang

https://github.com/afex/hystrix-go

golang 提供了拓展库(golang.org/x/time/rate)提供了限流器组件

微服务

https://github.com/douyu/jupiter

book

《Go语法树入门》(开源免费图书/Go语言进阶/掌握抽象语法树/Go语言AST/LLVM/LLIR) https://github.com/chai2010/go-ast-book

log

https://github.com/grafana/loki

流媒体

monibuca 丰富的内置插件提供了流媒体服务器的常见功能,例如rtmp server、http-flv、视频录制、QoS等 https://github.com/Monibuca 100star

Darwin Streaming Server 没有维护了? https://github.com/macosforge/dss

高性能开源RTSP流媒体服务器,基于go语言研发,维护和优化:RTSP推模式转发、RTSP拉模式转发、录像、检索、回放、关键帧缓存、秒开画面、RESTful接口、WEB后台管理、分布式负载均衡 https://github.com/EasyDarwin/EasyDarwin 4k

https://github.com/pion/ion https://github.com/pion/webrtc

IOT 平台? https://github.com/nats-io/nats-streaming-server

Chrome DevTools Protocol

https://github.com/chromedp/chromedp https://www.toutiao.com/i6843024797073408515

grpc

grpcui

他是一个 gRPC 的 Web 页面调试工具,提供交互式的调试界面。 https://github.com/fullstorydev/grpcui

grpcui -plaintext 127.0.0.1:9901 127.0.0.1:9901 是grpc server的地址

dingtalk

 1package dingtalk
 2
 3import (
 4    "bytes"
 5    "encoding/json"
 6    "errors"
 7    "io/ioutil"
 8    "net/http"
 9    "strconv"
10    "time"
11)
12
13// SendMessage 发送钉钉机器人消息
14func SendMessage(url, message string, ats ...string) (respContent string, err error) {
15    c := &http.Client{
16        Timeout: time.Second * 30,
17    }
18    data := map[string]interface{}{
19        "msgtype": "text",
20        "text":    map[string]string{"content": message},
21    }
22    if len(ats) != 0 {
23        isAtAll := false
24        atMobiles := []string{}
25        for i := range ats {
26            if ats[i] == "all" {
27                isAtAll = true
28            } else {
29                atMobiles = append(atMobiles, ats[i])
30            }
31        }
32        data["at"] = map[string]interface{}{
33            "isAtAll":   isAtAll,
34            "atMobiles": atMobiles,
35        }
36    }
37    b, _ := json.Marshal(data)
38    resp, err := c.Post(url, "application/json", bytes.NewReader(b))
39    if err != nil {
40        return "post请求失败", err
41    }
42    defer resp.Body.Close()
43    body, _ := ioutil.ReadAll(resp.Body)
44    if resp.StatusCode == 200 {
45        return string(body), nil
46    }
47    return string(body), errors.New(strconv.Itoa(resp.StatusCode))
48}
49
50package main
51
52import (
53    "fmt"
54    "dingtalk"
55)
56
57func main() {
58    result, err := dingtalk.SendMessage("https://oapi.dingtalk.com/robot/send?access_token=XXXXXX", "测试消息通知", "all")
59    if err != nil {
60        fmt.Println("发送失败", result)
61        return
62    }
63    fmt.Println("发送成功", result)
64}

WebAssembly

从Go到JavaScript的编译器,用于在浏览器中运行Go代码 https://github.com/gopherjs/gopherjs

https://github.com/hexops/vecty

js

esbuild

https://github.com/evanw/esbuild 这是一个 JavaScript 打包和压缩程序。它用于打包 JavaScript 和 TypeScript 代码以在网络上分发。 我目前有两个基准测试用于衡量 esbuild 的性能。对于这些基准测试,esbuild 比我测试的其他 JavaScript 打包程序 快至少 100 倍 :https://docs.breword.com/evanw-esbuild/

类似工具:

  • Webpack , Rollup 或 Parcel 用于打包
  • Babel 或 TypeScript 用于转译
  • Terser 或 UglifyJS 用于代码压缩

使用者:

  • Vite
  • Snowpack

Vite,snowpack使用了esbuild

esbuild 不可能替代 webpack、parcel 等构建工具

git

git sql

https://github.com/augmentable-dev/askgit

也可以跑docker docker run -v F:/github/openjw/openself:/repo:ro augmentable/askgit "SELECT * FROM commits"

Markdown

将 markdown 中的 go 代码块进行格式化。 https://github.com/po3rin/gofmtmd

https://github.com/JohannesKaufmann/html-to-markdown

嵌入文件

https://github.com/golang/proposal/blob/master/design/draft-embed.md#background

  • github.com/alecthomas/gobundle
  • github.com/GeertJohan/go.rice
  • github.com/go-playground/statics
  • github.com/gobuffalo/packr
  • github.com/knadh/stuffbin
  • github.com/mjibson/esc
  • github.com/omeid/go-resources
  • github.com/phogolabs/parcello
  • github.com/pyros2097/go-embed
  • github.com/rakyll/statik
  • github.com/shurcooL/vfsgen
  • github.com/UnnoTed/fileb0x
  • github.com/wlbr/templify
  • perkeep.org/pkg/fileembed

2020 年 10 月 30 日,Russ Cox 提交了最终的实现:[cmd/go: add //go:embed support](cmd/go: add //go:embed support),意味着你在 tip 版本可以试用该功能了。Go1.16 版本会包含该功能。 Embed 设计提案:https://github.com/golang/proposal/blob/master/design/draft-embed.md 示例参考:https://github.com/mattn/go-embed-example tip 相关文档:https://tip.golang.org

go-bindata

https://github.com/go-bindata/go-bindata

视频下载

https://github.com/iawia002/annie

抖音 https://www.douyin.com ✓ 哔哩哔哩 https://www.bilibili.com ✓ ✓ ✓ 半次元 https://bcy.net ✓ pixivision https://www.pixivision.net ✓ 优酷 https://www.youku.com ✓ ✓ YouTube https://www.youtube.com ✓ ✓ 爱奇艺 https://www.iqiyi.com ✓ 芒果TV https://www.mgtv.com ✓ 糖豆广场舞 http://www.tangdou.com ✓ ✓ Tumblr https://www.tumblr.com ✓ ✓ Vimeo https://vimeo.com ✓ Facebook https://facebook.com ✓ 斗鱼视频 https://v.douyu.com ✓ 秒拍 https://www.miaopai.com ✓ 微博 https://weibo.com ✓ Instagram https://www.instagram.com ✓ ✓ Twitter https://twitter.com ✓ 腾讯视频 https://v.qq.com ✓ 网易云音乐 https://music.163.com ✓ 音悦台 https://yinyuetai.com ✓ 极客时间 https://time.geekbang.org ✓ Pornhub https://pornhub.com ✓ XVIDEOS https://xvideos.com ✓ 聯合新聞網 https://udn.com ✓ TikTok https://www.tiktok.com ✓ 好看视频 https://haokan.baidu.com

go包搜索

https://api.godoc.org/search?q=etcd https://github.com/clearcodecn/gosearch

go多版本

https://github.com/owenthereal/goup

go测试

goc 是专为 Go 语言打造的一个综合覆盖率收集系统,尤其适合复杂的测试场景,比如系统测试时的代码覆盖率收集以及精准测试。 https://github.com/qiniu/goc

1go tool cover -mode=count -var=CoverageVariableName xxxx.go
2> 相信大家一定见过表示go覆盖率结果的coverprofile数据,类似下面: github.com/qiniu/goc/goc.go:21.13,23.2 1 1
3其基本语义为 "文件:起始行.起始列,结束行.结束列 该基本块中的语句数量 该基本块被执行到的次数"
4[聊聊 Go 代码覆盖率技术与最佳实践](https://xie.infoq.cn/article/ca1cc8ba293eddf793b3b0613)

go Plugin

  • go原生plugin

    • 实现机制基于动态链接so库
    • 跨语言支持较差且调用复杂,需解决不同语言的数据类型匹配问题
  • github.com/hashicorp/go-plugin

    • 实现机制基于rpc调用,基于本地网络调用,调用性能高效
    • 插件可用多种语言实现,跨语言支持良好

机器学习

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/go/README.md

流程图

https://github.com/blushft/go-diagrams 可以生成graphviz DOT file go-diagrams实现了diagrams的部分接口

http

http中间件negroni

https://github.com/urfave/negroni https://github.com/urfave/negroni#third-party-middleware

其它

一款用 SQL 方式查询 Git 仓库的开源项目进入 GitHub 趋势榜

https://github.com/augmentable-dev/gitqlite