上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 69 下一页

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 王景迁 阅读(11) 评论(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 王景迁 阅读(13) 评论(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 王景迁 阅读(10) 评论(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 王景迁 阅读(20) 评论(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 王景迁 阅读(19) 评论(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 王景迁 阅读(19) 评论(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 王景迁 阅读(99) 评论(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 王景迁 阅读(44) 评论(0) 推荐(0)

2025年6月9日

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

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

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

2025年6月7日

Linux sync同步数据到磁盘

摘要: 先创建好文件a.log内容是test2,再执行以下脚本。 echo "test3" > a.log cat a.log # 触发系统崩溃重启 bash -c "echo c > /proc/sysrq-trigger" 发现重启后还是test2。 触发系统崩溃重启前执行sync,保证文件内容是tes 阅读全文

posted @ 2025-06-07 18:46 王景迁 阅读(33) 评论(0) 推荐(0)

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 69 下一页

导航