2022年10月8日

packer demo

摘要: ks 应答文件demo install text reboot lang en_US.UTF-8 keyboard us timezone --utc Etc/UTC rootpw --plaintext 'kangwen12#$' zerombr autopart --type=plain --f 阅读全文

posted @ 2022-10-08 13:06 思此狂 阅读(66) 评论(0) 推荐(0) 编辑

2022年7月10日

gin demo

摘要: gin demo 演示参数校验 package main import ( "fmt" "io/ioutil" "net/http" "github.com/gin-gonic/gin" // "context" ) type Userinfo struct { Username string `f 阅读全文

posted @ 2022-07-10 22:01 思此狂 阅读(242) 评论(0) 推荐(0) 编辑

context取消任务demo

摘要: 一个基于 gin 的demo ,支持 创建任务, 停止(取消)任务 -》基于 context cancle, 查询任务 传递任务id 基于 context value package main import ( "fmt" "math/rand" "strconv" "context" "time" 阅读全文

posted @ 2022-07-10 21:58 思此狂 阅读(127) 评论(0) 推荐(0) 编辑

2022年4月17日

go 执行系统命令

摘要: 文档: go 执行命令的5种方法 https://zhuanlan.zhihu.com/p/296409942 package main import ( "bytes" "fmt" "log" "os/exec" ) var cmd = ` echo hello echo world >&2 ex 阅读全文

posted @ 2022-04-17 19:26 思此狂 阅读(1783) 评论(0) 推荐(0) 编辑

2021年12月12日

new & make

摘要: package main import "fmt" // 执行下面的代码会引发panic,为什么呢? 在Go语言中对于引用类型的变量, // 我们在使用的时候不仅要声明它,还要为它分配内存空间,否则我们的值就没办法存储。 // 而对于值类型的声明不需要分配内存空间,是因为它们在声明的时候已经默认分配 阅读全文

posted @ 2021-12-12 01:32 思此狂 阅读(32) 评论(0) 推荐(0) 编辑

值传递和引用传递

摘要: package main import "fmt" func addtest1(x,y int) int { x = x + 1 y = y + 1 return x + y } func addtest2(x, y *int) int { *x = *x + 1 *y = *y + 1 retur 阅读全文

posted @ 2021-12-12 01:28 思此狂 阅读(22) 评论(0) 推荐(0) 编辑

2021年8月15日

shell的文件锁操作

摘要: flock { flock -n 3 [ $? -eq 1 ] && echo "anoter prossess is running" && exit 1 sleep 10 echo helloworld11 sleep 3 echo helloworld22 } 3>/root/1.lock 阅读全文

posted @ 2021-08-15 19:25 思此狂 阅读(568) 评论(0) 推荐(0) 编辑

2021年7月29日

systemd target

摘要: Runlevel 0== poweroff.target Runlevel 1== rescue.target Runlevel 2== multi-user.target Runlevel 3== multi-user.target Runlevel 4== multi-user.target R 阅读全文

posted @ 2021-07-29 23:08 思此狂 阅读(160) 评论(0) 推荐(0) 编辑

2021年1月17日

关于网络中断

摘要: 阿里云ECS 配置网卡多队列 提升中断处理性能 https://help.aliyun.com/document_detail/52559.html?spm=a2c4g.11174283.6.990.b2e552fekaIQx9 关于亲和性设置 https://www.cnblogs.com/bam 阅读全文

posted @ 2021-01-17 21:49 思此狂 阅读(162) 评论(0) 推荐(0) 编辑

2021年1月4日

python对象判断isintance/is等

摘要: isintance/type 的区别尽量使用isintance 内置的 type() 函数可以用来查询变量所指的对象类型。isinstance(1, int) 区别: class A: pass class B(A): pass isinstance(A(), A) # returns True t 阅读全文

posted @ 2021-01-04 23:30 思此狂 阅读(228) 评论(0) 推荐(0) 编辑

导航