随笔分类 -  go

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 思此狂 阅读(102) 评论(0) 推荐(0) 编辑

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 思此狂 阅读(282) 评论(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 思此狂 阅读(138) 评论(0) 推荐(0) 编辑

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 思此狂 阅读(1805) 评论(0) 推荐(0) 编辑

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

posted @ 2021-12-12 01:32 思此狂 阅读(33) 评论(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 思此狂 阅读(23) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示