跳过正文

Go

2025

独属于技术宅的浪漫
·9 字
独属于技术宅的浪漫
golang base64编解码问题
·398 字
由于业务需要,go 服务需要调用 java 服务接口,其中需要对参数进行 base64 编解码

2024

gvm管理go版本
·18 字
使用gvm管理Go版本 moovweb/gvm Go Version Manager
Json Web Token
·663 字
官网:jwt.io jwt的优势 jwt无状态, 服务端不需要存储jwt,没有存储压力 跨域支持,前端的移动端、桌面端都可以使用,可以很方便的实现sso 缺点
Go语言技巧
·693 字
Defer两阶段延迟执行 # 记录函数执行时间

2023

pprof分析
·606 字
服务增加 pprof 监控 # package main import( "net/http" _ "net/http/pprof" ) func main() { go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }() // do something } pprof 包初始化方法里注册了相关路由地址
获取图片信息
·360 字
获取远程图片信息 # image库针对远程图片使用image.Decode()方法进行解析时,会遇到无法解析图片格式的情况;
Sentinel Golang
·1702 字
限流规则 # // Strategy type TokenCalculateStrategy int32 const ( Direct TokenCalculateStrategy = iota WarmUp MemoryAdaptive ) // Rule describes the strategy of flow control, the flow control strategy is based on QPS statistic metric type Rule struct { // ID represents the unique ID of the rule (optional). ID string `json:"id,omitempty"` // Resource represents the resource name. Resource string `json:"resource"` TokenCalculateStrategy TokenCalculateStrategy `json:"tokenCalculateStrategy"` ControlBehavior ControlBehavior `json:"controlBehavior"` // Threshold means the threshold during StatIntervalInMs // If StatIntervalInMs is 1000(1 second), Threshold means QPS Threshold float64 `json:"threshold"` RelationStrategy RelationStrategy `json:"relationStrategy"` RefResource string `json:"refResource"` // MaxQueueingTimeMs only takes effect when ControlBehavior is Throttling. // When MaxQueueingTimeMs is 0, it means Throttling only controls interval of requests, // and requests exceeding the threshold will be rejected directly. MaxQueueingTimeMs uint32 `json:"maxQueueingTimeMs"` WarmUpPeriodSec uint32 `json:"warmUpPeriodSec"` WarmUpColdFactor uint32 `json:"warmUpColdFactor"` // StatIntervalInMs indicates the statistic interval and it's the optional setting for flow Rule. // If user doesn't set StatIntervalInMs, that means using default metric statistic of resource. // If the StatIntervalInMs user specifies can not reuse the global statistic of resource, // sentinel will generate independent statistic structure for this rule. StatIntervalInMs uint32 `json:"statIntervalInMs"` // adaptive flow control algorithm related parameters // limitation: LowMemUsageThreshold > HighMemUsageThreshold && MemHighWaterMarkBytes > MemLowWaterMarkBytes // if the current memory usage is less than or equals to MemLowWaterMarkBytes, threshold == LowMemUsageThreshold // if the current memory usage is more than or equals to MemHighWaterMarkBytes, threshold == HighMemUsageThreshold // if the current memory usage is in (MemLowWaterMarkBytes, MemHighWaterMarkBytes), threshold is in (HighMemUsageThreshold, LowMemUsageThreshold) LowMemUsageThreshold int64 `json:"lowMemUsageThreshold"` HighMemUsageThreshold int64 `json:"highMemUsageThreshold"` MemLowWaterMarkBytes int64 `json:"memLowWaterMarkBytes"` MemHighWaterMarkBytes int64 `json:"memHighWaterMarkBytes"` } 熔断规则 # 熔断规则
链表
·358 字
链表简述 # 链表(Linked list)是一种常见的基础数据结构,是一种线性表,但是并不会按线性的顺序存储数据,而是在每一个节点里存到下一个节点的指针(Pointer)。由于不必须按顺序存储,链表在插入的时候可以达到O(1)的复杂度,比另一种线性表顺序表快得多,但是查找一个节点或者访问特定编号的节点则需要O(n)的时间,而顺序表相应的时间复杂度分别是O(logn)和O(1)
Zap日志包
·410 字
zap # go get -u go.uber.org/zap