Skip to content

Commit

Permalink
go
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomeng79 committed Dec 6, 2018
1 parent 096573e commit f2a7904
Show file tree
Hide file tree
Showing 14 changed files with 172 additions and 30 deletions.
119 changes: 100 additions & 19 deletions 01语言/1go/7常用的包.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,37 @@
- [heroku](https://www.heroku.com/) 持续部署
- [shields](https://shields.io/#/) 生成图标
- [katacoda](https://www.katacoda.com/) 真实模拟
- [How-to-Make-a-Computer-Operating-System](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System) 如何做一个操作系统


##

### 框架

[go-micro](https://github.com/micro/go-micro) 插件话微服务框架
[echo](https://github.com/labstack/echo) 轻量web框架
- [go-micro](https://github.com/micro/go-micro) 插件话微服务框架
- [echo](https://github.com/labstack/echo) 轻量web框架
- [tango](https://github.com/lunny/tango) web中间件
- [go-grpc-middleware](https://github.com/grpc-ecosystem/go-grpc-middleware) grpc中间件
- [chess](https://github.com/gochenzl/chess) 棋牌游戏框架
- [leaf](https://github.com/name5566/leaf) 游戏框架
- [ebiten](https://github.com/hajimehoshi/ebiten) 2D游戏库
- [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway)
- [mqtt](https://github.com/zentures/surgemq) mqtt库
- [iris](https://github.com/kataras/iris) web框架
- [livego](https://github.com/gwuhaolin/livego) 直播框架
- [mqant](https://github.com/liangdas/mqant) 游戏框架

### 网关

- [traefik](https://github.com/containous/traefik) 基于容器的网关
- [kong](https://github.com/Kong/kong)

### Metric Logging Traceing

- [go-metrics](github.com/rcrowley/go-metrics)
- [opentracing-go](https://github.com/opentracing/opentracing-go)
- [prometheus](https://github.com/prometheus/prometheus)
- [opencensus-go](https://github.com/census-instrumentation/opencensus-go)

### 模板

Expand All @@ -31,33 +50,95 @@
- [go-bindata](https://github.com/jteeuwen/go-bindata) 静态文件打包成二进制


### 测试
### 常用的库

- [testify](https://github.com/stretchr/testify) 代码测试,断言和模拟的工具包
- [goconvey](https://github.com/smartystreets/goconvey) go测试
- [govalidator](https://github.com/asaskevich/govalidator) 数据验证
- [gomail](https://github.com/go-gomail/gomail) 发送邮件
- [json](https://github.com/json-iterator/go) json编码解码
- [configor](https://github.com/jinzhu/configor) 配置文件
- [uuid](https://github.com/satori/go.uuid) UUID
- [mgo](https://github.com/go-mgo/mgo) mongodb
- [bolt](https://github.com/boltdb/bolt) K/V文件存储,支持事务,适合读多写少 B+树
- [leveldb](https://github.com/golang/leveldb) [goleveldb](https://github.com/syndtr/goleveldb) K/V存储,不支持事务,适合读少写多 
- [dgraph](https://github.com/dgraph-io/dgraph) 图数据库
- [cayley](https://github.com/cayleygraph/cayley) 图数据库
- [influxdb](https://github.com/influxdata/influxdb) 时序数据库
- [gohbase](https://github.com/tsuna/gohbase) hbase客户端
- [cetus](https://github.com/Lede-Inc/cetus) mysql中间件
- [sqlx](https://github.com/jmoiron/sqlx) 构建sql
- [sarama](https://github.com/Shopify/sarama) kafka客户端
- [gorm](https://github.com/jinzhu/gorm) gorm
- [redigo](https://github.com/gomodule/redigo) redis客户端

### JWT

- [jwt](https://github.com/dgrijalva/jwt-go) JWT

### 限流
### 算法

- [ratelimit](go.uber.org/ratelimit) 优步限流
- [gobreaker](https://github.com/sony/gobreaker) 断路器
- [snowflake](https://github.com/bwmarrin/snowflake) 雪花算法


### 生成文档
### 机器学习

- [go-swagger](https://github.com/go-swagger/go-swagger) 生成文档,目前不支持go mod
- [CloudForest](https://github.com/ryanbressler/CloudForest) 决策树
- [golearn](https://github.com/sjwhitworth/golearn) 机器学习
- [goml](https://github.com/cdipaolo/goml) 机器学习
- [gorgonia](https://github.com/gorgonia/gorgonia) 机器学习

### 数据存储
### 不常用的库

- [bolt](https://github.com/boltdb/bolt) K/V文件存储,支持事务,适合读多写少 B+树
- [leveldb](https://github.com/golang/leveldb) [goleveldb](https://github.com/syndtr/goleveldb) K/V存储,不支持事务,适合读少写多 

### ORM

- [gorm](https://github.com/jinzhu/gorm)

### 验证码
- [decimal](https://github.com/shopspring/decimal) 浮点数精度
- [drwmutex](https://github.com/jonhoo/drwmutex) 分布式读写锁
- [captcha](https://github.com/dchest/captcha) 验证码
- [base64Captcha](https://github.com/mojocn/base64Captcha) 验证码
- [jwt](https://github.com/dgrijalva/jwt-go) JWT
- [gopher-lua](https://github.com/yuin/gopher-lua) go编译lua
- [go-swagger](https://github.com/go-swagger/go-swagger) 生成文档,目前不支持go mod
- [go-socket.io](https://github.com/googollee/go-socket.io) socket.io库
- [kcp-go](https://github.com/xtaci/kcp-go) 生产级的UDP库
- [watcher](https://github.com/radovskyb/watcher)
- [gopsutil](https://github.com/shirou/gopsutil) go查看进程信息工具
- [negroni](https://github.com/urfave/negroni) 原生web中间件
- [lumberjack](https://github.com/natefinch/lumberjack) 文件滚动切分
- [mergo](https://github.com/imdario/mergo) map和结构合并
- [fsnotify](https://github.com/fsnotify/fsnotify) 跨平台文件变化通知
- [httprouter](https://github.com/julienschmidt/httprouter) 路由
- [websocket](https://github.com/gorilla/websocket) websocket库


### 区块链

- [blockchain-tutorial](https://github.com/liuchengxu/blockchain-tutorial)

### 需要研究的项目

- [gorush](https://github.com/xiaomeng79/gorush) go推送
- [centrifugo](https://github.com/xiaomeng79/centrifugo) 语言无关的消息推送
- [mahjong](https://github.com/jxbdlut/mahjong) 游戏麻将


### 学习资料

- [architect-awesome](https://github.com/xingshaocheng/architect-awesome) 后端架构师技术图谱
- [Qix](https://github.com/ty4z2008/Qix)
- [awesome-go-zh](https://github.com/chai2010/awesome-go-zh)
- [raft](https://github.com/maemual/raft-zh_cn) raft
- [DeepLearning-500-questions](https://github.com/scutan90/DeepLearning-500-questions) 深度学习
- [nginx-book](https://github.com/taobao/nginx-book) nginx学习
- [gonote](https://github.com/xmge/gonote)
- [golang-swaggerui-example](https://github.com/ribice/golang-swaggerui-example)
- [project-layout](https://github.com/golang-standards/project-layout)
- [php](https://github.com/JingwenTian/awesome-php)
- [night-reading-go](https://github.com/developer-learning/night-reading-go)
- [Python-100-Days](https://github.com/jackfrued/Python-100-Days)
- [project-based-learning](https://github.com/tuvtran/project-based-learning) **
- [Halfrost-Field)](https://github.com/halfrost/Halfrost-Field)
- [CS-Notes](https://github.com/CyC2018/CS-Notes)
- [golang-open-source-projects](https://github.com/hackstoic/golang-open-source-projects)
- [awesome-blockchain-cn](https://github.com/chaozh/awesome-blockchain-cn) 区块链资料
- [shippy](https://github.com/EwanValentine/shippy) 微服务示例
- [The-Golang-Standard-Library-by-Example](https://github.com/polaris1119/The-Golang-Standard-Library-by-Example) go标准库

- [captcha](https://github.com/dchest/captcha)

10 changes: 10 additions & 0 deletions 02数据存取/1mysql/0目录.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,15 @@

5. [Innodb和myisam区别](./5Innodb和myisam区别.md)

6. [mysql设计规范](./6mysql设计规范.md)

7. [数据库垂直拆分](./7数据库垂直拆分.md)

8. [DB主从一致性架构优化](./8DB主从一致性架构优化.md)

9. [索引](./9索引.md)

10. [](./10锁.md)



6 changes: 6 additions & 0 deletions 02数据存取/1mysql/2查询优化.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ myisam索引的叶子节点存储的是数据地址,innodb索引的叶子节点

如果表使用自增主键,那么每次插入新的记录,记录就会顺序添加到当前索引节点的后续位置,当一页写满,就会自动开辟一个新的页,使用非自增索引将会破坏原来的结构

### 常见优化

1. 如果明确知道只有一条结果返回,limit 1能够提高效率,明确告诉数据库,让它主动停止游标移动
2. 强制类型转换会全表扫描
3. 只返回需要的列,能够大大的节省数据传输量,与数据库的内存使用量
4. 负向查询肯定不能命中索引

4 changes: 3 additions & 1 deletion 03容器和集群/0目录.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

1. [docker](./1docker/0目录.md)

2. [k8s](./2k8s/0目录.md)
2. [k8s](./2k8s/0目录.md)

3. [服务网格](./3服务网格/0目录.md)
2 changes: 1 addition & 1 deletion 03容器和集群/2k8s/2命令.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#### k8s拉去私有仓库image

```shell
kubectl create secret docker-registry registry-secret --docker-server=registry.cn-shenzhen.aliyuncs.com --docker-username=mengqingfang@zingsq --docker-password=mqf19890715 --docker-email=mengqingfang@zingsq -n default
kubectl create secret docker-registry registry-secret --docker-server=registry.cn-shenzhen.aliyuncs.com --docker-username=mengqingfang@*** --docker-password= --docker-email=mengqingfang@zingsq -n default

--docker-server: 仓库地址
--docker-username: 仓库登陆账号
Expand Down
4 changes: 4 additions & 0 deletions 03容器和集群/3服务网格/0目录.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 目录

- [istio](https://github.com/istio/istio)
- [官网](https://istio.io)
4 changes: 3 additions & 1 deletion 06工具/list.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
1. https://asciinema.org/ 命令行记录
1. https://asciinema.org/ 命令行记录
2. https://github.com/buger/goreplay 流量重放
3. https://github.com/erguotou520/electron-ssr
2 changes: 2 additions & 0 deletions 07分布式系统/0目录.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
8. [一致性协议](./8一致性协议.md)

9. [服务发现](./9服务发现.md)

10. [微服务](./10微服务.md)
8 changes: 8 additions & 0 deletions 07分布式系统/10微服务.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## 微服务

### 解决什么问题
1. 代码到处拷贝
2. 消除复杂性扩散(一处BUG处处修改,专注性,屏蔽底层复杂度)
3. SQL质量得不到保障,业务相互影响(拒绝其他业务直接操作数据层)
4. 调用方爽(像操作一个本地函数)
5. 提供有限接口,无限性能
3 changes: 2 additions & 1 deletion 16架构/000常见设计.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## 常见设计

1. [商品SKU设计](https://blog.csdn.net/wwwdc1012/article/details/71774280/)
1. [商品SKU设计](https://blog.csdn.net/wwwdc1012/article/details/71774280/)

16 changes: 9 additions & 7 deletions 16架构/1负载均衡.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

[参考](http://lobert.iteye.com/blog/2159970)

[架构之家](https://mp.weixin.qq.com/s/4dzqbh2wfzbQzgFodP2_6Q)

根据服务器的能力(硬件),承担相应的工作,是解决高性能,单点故障(高可用),扩展性(水平伸缩)的终极解决方案

### 作用
Expand Down Expand Up @@ -33,15 +35,12 @@

**一般将DNS作为第一级负载均衡,A记录对应着内部负载均衡的IP地址**

##### 特性

1. 可以根据用户IP来进行智能解析。DNS服务器可以在所有可用的A记录中寻找离用记最近的一台服务器。
2. 动态DNS:在每次IP地址变更时,及时更新DNS服务器。当然,因为缓存,一定的延迟不可避免。

##### 缺点

1. 各级节点的DNS服务器不同程序的缓存会让你晕头转向
2. 无法根据实际服务器的实时负载差异来调整调度策略
1. 扩容非实时
2. 非高可用,只负责解析ip,不负责探活
3. 暴露太多外网ip

#### 反向代理负载均衡

Expand All @@ -55,7 +54,10 @@

##### 缺陷

对反向代理服务器要求高,需要keeplive监控心跳
对反向代理服务器要求高,需要keeplive监控心跳,单机有上限和时延增加

#### LVS
lvs:Linux Virtual Server,使用集群技术,实现在linux操作系统层面的一个高性能、高可用、负载均衡服务器

#### IP负载均衡(LVS-NAT)

Expand Down
6 changes: 6 additions & 0 deletions 16架构/2概念.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 概念

### 高可用
通过设计减少程序不可访问的时间
### 高并发
通过设计让程序能够在单位时间内处理更多的请求
5 changes: 5 additions & 0 deletions 16架构/3跨公网调用优化.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 跨公网调用第三方服务

- 业务能接受旧数据:读取本地数据,异步代理定期更新数据
- 有多个第三方服务提供商:多个第三方互备(短信)
- 向第三方同步数据:本地写成功就算成功,异步向第三方同步数据
13 changes: 13 additions & 0 deletions 16架构/4秒杀系统.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## 秒杀系统:

### 思路

1. 将请求拦截在上游
2. 充分利用缓存

#### 具体方案

- 客户端层: 按钮置灰,禁止用户重复提交请求;
- 客户端层:JS限制用户在x秒之内只能提交一次请求
- 站点层: 页面缓存,返回同一个页面,同一个用户限流
- 服务层: 请求队列,超量直接返回"已售完"

0 comments on commit f2a7904

Please sign in to comment.