摘要: ####### 使用ws 订阅人员变更信息 package main import ( "fmt" "github.com/gorilla/websocket" "log" "os" "os/signal" "time" ) func main() { // install signal inter 阅读全文
posted @ 2022-05-10 19:29 vx_guanchaoguo0 阅读(514) 评论(0) 推荐(0)
摘要: 服务端代码 package main import ( "fmt" "net/http" "sync" "github.com/gorilla/websocket" ) var upgrader = websocket.Upgrader{ ReadBufferSize: 1024, WriteBuf 阅读全文
posted @ 2022-05-09 22:25 vx_guanchaoguo0 阅读(112) 评论(0) 推荐(0)
摘要: md5 两种方式摘要 直接sum 是长度为16的byte 转为16进制输出 data := []byte(str) has := md5.Sum(data) fmt.Println(fmt.Sprintf("%x", has) ) 生成一个hash 接口对象 将字符串写入 转为16进制输出 w := 阅读全文
posted @ 2022-05-09 14:08 vx_guanchaoguo0 阅读(61) 评论(0) 推荐(0)
摘要: 背景 需要安装webplayer 但是chrome 不支持(知道请告诉我)就需要已360急速为主 两个浏览器电脑有点卡 chrome 拓展目录 C:\Users\Administrator\AppData\Local\Google\Chrome\User Data\Default\Extension 阅读全文
posted @ 2022-05-09 11:14 vx_guanchaoguo0 阅读(58) 评论(0) 推荐(0)
摘要: 在win上构建二进制程序到 linux 运行 SET CGO_ENABLED=0 SET GOOS=linux SET GOARCH=amd64 go build -mod=vendor [-o <binary_name>] main.go CGO_ENABLED=0 GOOS=linux GOAR 阅读全文
posted @ 2022-05-07 14:43 vx_guanchaoguo0 阅读(31) 评论(0) 推荐(0)
摘要: 免密登录配置 客户端生成公钥私钥对 服务端保存公钥到 authorized_keys [scp/ssh-copy-id] /etc/ssh/sshd_config 配置重启 know_hosts 会记录链接主机信息 首次会询问 原理解析 在客户端使用ssh-keygen生成一对密钥:公钥+私钥 将客 阅读全文
posted @ 2022-04-29 20:32 vx_guanchaoguo0 阅读(80) 评论(0) 推荐(0)
摘要: 很多人认为 父 goroutine 结束后 子goroutine 一定会结束 结论只要main 不结束 goroutine 一定会运行 代码验证 package main import ( "fmt" "time" ) func main() { fmt.Println("main start") 阅读全文
posted @ 2022-04-29 20:13 vx_guanchaoguo0 阅读(135) 评论(0) 推荐(0)
摘要: 都知道map并发是不安全 会被运行时panic ####### sync.Map 源码解析 type Map struct { mu Mutex read atomic.Value // readOnly dirty map[interface{}]*entry misses int } type 阅读全文
posted @ 2022-04-29 20:05 vx_guanchaoguo0 阅读(44) 评论(0) 推荐(0)
摘要: 官方一段话 time.After 内存gc 不会回收 其实不是 源码 / After waits for the duration to elapse and then sends the current time // on the returned channel. // It is equiv 阅读全文
posted @ 2022-04-29 19:53 vx_guanchaoguo0 阅读(65) 评论(0) 推荐(0)
摘要: ######很多人在博客看到 slice 扩容策略如下 当大于 1024 则1.5倍 大于1024则两倍 这个结论是错误的 a:= []int{1,2} a= append(a,3,4,5) // 如果是2倍应该 容量是8 但是实际 5 ####### 查阅源码 runtime/slice.go f 阅读全文
posted @ 2022-04-29 19:46 vx_guanchaoguo0 阅读(29) 评论(0) 推荐(0)