上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 74 下一页

2025年7月18日

go 设置http请求超时时间

摘要: 10.11.12.13不真实存在,ping会超时。 使用 http.Client 设置全局超时 package main import ( "net/http" "time" ) func main() { client := &http.Client{ Timeout: 5 * time.Seco 阅读全文

posted @ 2025-07-18 08:09 王景迁 阅读(115) 评论(0) 推荐(0)

2025年7月12日

go 切片删除某个元素

摘要: package main import "fmt" func delete(s []int, num int) []int { for i := 0; i < len(s); i++ { if s[i] == num { s = append(s[:i], s[i+1:]...) i-- } } r 阅读全文

posted @ 2025-07-12 17:31 王景迁 阅读(25) 评论(0) 推荐(0)

2025年6月28日

Makefile用途

摘要: 用途1:构建docker镜像 mkdir makefile cd makefile # Dockerfile FROM golang:1.19-alpine AS builder # Makefile build: docker build -t $(tag) . make build tag=a 阅读全文

posted @ 2025-06-28 10:18 王景迁 阅读(23) 评论(0) 推荐(0)

2025年6月22日

go 使用options扩展参数

摘要: package main import ( "fmt" ) type Config struct { path string isUseFile bool } type ConfigOption func(config *Config) error func WithPath(path string 阅读全文

posted @ 2025-06-22 16:17 王景迁 阅读(28) 评论(0) 推荐(0)

go url parse

摘要: url = schema(http/https) + "//" + host(ip:port/domain:port) + path(/xxx) + "?" + rawQuery(xxx=xxx) package main import ( "fmt" "net/url" ) func parseU 阅读全文

posted @ 2025-06-22 11:50 王景迁 阅读(31) 评论(0) 推荐(0)

2025年6月21日

go context value保存map

摘要: go context虽然只能保存一对key和value,但是支持any;虽然获取value时支持不断从父context中找,但是无法获取所有kv。 package main import ( "maps" "context" "fmt" ) // context推荐使用自定义结构体类型作为key,与 阅读全文

posted @ 2025-06-21 11:00 王景迁 阅读(46) 评论(0) 推荐(0)

2025年6月20日

go https代理认证

摘要: curl --proxy-header "代理认证信息" --proxy "代理地址" https://xxx 这里--proxy-header和普通header -H不等价,虽然两者类型相同,但是前者只发送给代理服务端(仅限https场景),后者只发送给服务端。 go Transport实现了ht 阅读全文

posted @ 2025-06-20 22:04 王景迁 阅读(43) 评论(0) 推荐(0)

2025年6月17日

grpc常见报错

摘要: 报错1:rpc error:code=DeadlineExceeded desc = context deadline exceeded原因:客户端context超时时间小于服务端响应时间。解决:gRPC客户端建议显式指定超时时间,延长客户端超时时间。 ctx, cancel := context. 阅读全文

posted @ 2025-06-17 09:08 王景迁 阅读(199) 评论(0) 推荐(0)

2025年6月15日

iptables规则中配置ipset

摘要: # 创建ipset ipset create white-list hash:ip ips="10.0.0.1,10.0.0.2,10.0.0.3" # 根据逗号切割 ipArr=(${ips//\,/ }) for item in "${ipArr[@]}" do # 增加单个ip ipset a 阅读全文

posted @ 2025-06-15 21:43 王景迁 阅读(66) 评论(0) 推荐(0)

2025年6月9日

Linux 查看最近一次系统启动时间

摘要: who -b uptime -s 阅读全文

posted @ 2025-06-09 08:38 王景迁 阅读(33) 评论(0) 推荐(0)

上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 74 下一页

导航