Go
69 篇笔记
- 4.4 Golang内存泄露historical
1. 内存泄露 内存泄露.md 2. Golang内存泄露 2.1. root对象引用 2.2. goroutine 泄漏 goroutine泄露:原理、场景、检测和防范 \- SegmentFault 思否 - 如果你启动了一个 goroutine,但并没有符合预期的退出,那么直到程序结束这个go
- 4.5 tracehistorical
1. 使用 步骤如下: 1. 导入包: import runtime/trace 2. 开启分析: trace.Start(file) 停止分析: trace.Stop() 3. 命令行分析 - go tool trace trace.out - 2. 参考 Go execution tracer
- consulhistorical
1. 是什么 服务注册与发现的组件 2. 单机集群搭建 2.1. 下载 Download Consul \ Consul by HashiCorp 2.2. 配置文件 2.2.1. 创建目录 2.2.2. 配置文件 server1 server2 server3 2.3. 启动 server1 server2 server3 2.4. 测试 增加服务配置文件 增加服务 web ui 3. 参考 Consul集群搭建 \ 简书 WEHou
- etcdhistorical
1. 安装 下载 Releases · etcd\ io/etcd 解压配置环境变量 2. web ui Releases · evildecay/etcdkeeper 3. 参考 etcd \ Home
- hystrixhistorical
1. circuit golang版本的hystrix实现,用于服务熔断(降级的一种措施,其他如开关熔断等) 2. 使用 hystrix.go main.go 3. 参考 cep21/circuit: An efficient and feature complete Hystrix like Go implementation of the circuit breaker pattern\. expvar \ The Go Progr
- microhistorical
1. 安装micro 1.1. 方案一 下载 Releases · micro/micro 解压配置环境变量 1.2. 方案二 前提是配置好GOBIN环境变量 下载源码 安装到GOBIN中 2. 参考 micro/micro: Micro is a distributed systems runtime for the Cloud Micro \ The fastest way to build services in the Clou
- protobufhistorical
1. 是什么 高效的序列化、反序列化方式 1.1. 普通序列化 Teacher Test 结果 可以看出字节数挺大的 1.2. protobuf序列化 TearchSerializer.proto 生成Java Test 结果 可以看出生成的字节数小 1.3. 对比 protobuf序列化的时候减少了一些额外的信息 比如int占用4个字节,而protobuf则是根据长度占用1 5个字节 1.3.1. 普通的序列化反序列化 1.3.2.
- retryhistorical
1. 是什么 调用远程服务失败,重新调用一次有可能就成功了 2. 什么时候需要重试 网络错误能重试,逻辑错误没必要 当网络错误长时间持续的时候不能使用重试,防止进一步压垮服务 不是幂等请求,不能重试 3. 重试策略 快速失败和重试的权衡 如果重试多次之后还是失败,那么不应该继续重试。参考断路器模式 4. Golang重试 4.1. retry 相当于golang版本的ribbon,定义重试策略 5. 参考 avast/retry\ go
- Go环境搭建historical
1. 安装Golang 1.1. 下载 Downloads \ The Go Programming Language 1.2. 配置环境变量 Windows直接右键计算机修改环境变量,重启生效 Linux一般修改/etc/profile,然后source /etc/profile生效 新版本的golang可以用 go env w 变量名="" 来设置环境变量,存储于 <USER HOME \AppData\Roaming\go\env