Golang 那些必知的网址
golang 包搜索:
https://pkg.go.dev
代理:
https://goproxy.cn
学习网址:
https://www.topgoer.com/
Golang标准库文档
https://studygolang.com/pkgdoc
gorm:
https://gorm.io/
beego:
https://beego.vip/
gin
开发文档
https://gin-gonic.com/zh-cn/docs/introduction/
https://www.bookstack.cn/read/gin-docs-zh/579a2310c9e850c5.md
命令执行:
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:/Users/用户名/go/bin
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
export GOPATH=/Users/用户名/go
Goals
我们致力于提供完整的微服务研发体验,整合相关框架及工具后,微服务治理相关部分可对整体业务开发周期无感,从而更加聚焦于业务交付。对每位开发者而言,整套Kratos框架也是不错的学习仓库,可以了解和参考到bilibili在微服务方面的技术积累和经验。
Features
APIs:协议通信以 HTTP/gRPC 为基础,通过 Protobuf 进行定义;
Errors:通过 Protobuf 的 Enum 作为错误码定义,以及工具生成判定接口;
Metadata:在协议通信 HTTP/gRPC 中,通过 Middleware 规范化服务元信息传递;
Config:支持多数据源方式,进行配置合并铺平,通过 Atomic 方式支持动态配置;
Logger:标准日志接口,可方便集成三方 log 库,并可通过 fluentd 收集日志;
Metrics:统一指标接口,可以实现各种指标系统,默认集成 Prometheus;
Tracing:遵循 OpenTelemetry 规范定义,以实现微服务链路追踪;
Encoding:支持 Accept 和 Content-Type 进行自动选择内容编码;
Transport:通用的 HTTP/gRPC 传输层,实现统一的 Middleware 插件支持;
Registry:实现统一注册中心接口,可插件化对接各种注册中心;
https://github.com/go-kratos/kratos
https://go-kratos.dev/docs/getting-started/start/
Go 语言设计与实现:
https://draveness.me/golang/
微信SDK For Golang:
https://silenceper.com/wechat/
简要AB测试:
gin "hello world": ( Requests per second: 9653.91 [#/sec] (mean) )
ab -c100 -n1000 http://127.0.0.1:9999/ping
Server Software: Server Hostname: 127.0.0.1 Server Port: 9999 Document Path: /ping Document Length: 13 bytes Concurrency Level: 100 Time taken for tests: 0.104 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 136000 bytes HTML transferred: 13000 bytes Requests per second: 9653.91 [#/sec] (mean) Time per request: 10.358 [ms] (mean) Time per request: 0.104 [ms] (mean, across all concurrent requests) Transfer rate: 1282.16 [Kbytes/sec] received
beego "hello world": ( Requests per second: 686.36 [#/sec] (mean) )
ab -c100 -n1000
Server Software: beegoServer:2.0.0 Server Hostname: 127.0.0.1 Server Port: 8081 Document Path: / Document Length: 70185 bytes Concurrency Level: 100 Time taken for tests: 1.457 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 70331000 bytes HTML transferred: 70185000 bytes Requests per second: 686.36 [#/sec] (mean) Time per request: 145.696 [ms] (mean) Time per request: 1.457 [ms] (mean, across all concurrent requests) Transfer rate: 47140.92 [Kbytes/sec] received
PHP + Nginx: ( Requests per second: 388.28 [#/sec] (mean) )
ab -c100 -n1000 http://127.0.0.1/xx.html
Server Software: nginx/1.19.3 Server Hostname: 127.0.0.1 Server Port: 80 Document Path: /xx.html Document Length: 153 bytes Concurrency Level: 100 Time taken for tests: 2.575 seconds Complete requests: 1000 Failed requests: 0 Non-2xx responses: 1000 Total transferred: 350000 bytes HTML transferred: 153000 bytes Requests per second: 388.28 [#/sec] (mean) Time per request: 257.547 [ms] (mean) Time per request: 2.575 [ms] (mean, across all concurrent requests) Transfer rate: 132.71 [Kbytes/sec] received
golang 开发自动编译方式: fresh
下载fresh包: go get github.com/pilu/fresh 进入你的项目目录: 执行 fresh
Nginx 配置文件:
location ~ (/api/|/admin/) { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, DELETE'; add_header Access-Control-Allow-Headers 'DNT,Keep-Alive,User-Agent,Cache-Control,Content-Type,Authorization,X-Token'; if ($request_method = 'OPTIONS') { return 204; } # 将客户端的 Host 和 IP 信息一并转发到对应节点 proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 执行代理访问真实服务器 proxy_pass http://127.0.0.1:9999; }