随笔分类 - golang
摘要:package shell import ( "context" "fmt" "os/exec" "time" ) // 自定义输出结构体 type customOutput struct { outPut chan string resetCtx chan struct{} } // Write
阅读全文
摘要:func YesNO(choose bool) { userFile := "/dev/tty" if !choose { here: fmt.Printf("Continue (y/n):") fin, err := os.Open(userFile) defer fin.Close() if e
阅读全文
摘要:1、设置home hbrew 安装protobuf brew install protobuf 2、设置gomod模式 GO111MODULE=off无模块支持,go 会从 $GOPATH 文件夹和 vendor 目录中寻找依赖项。 GO111MODULE=on模块支持,go 忽略 $GOPATH
阅读全文
摘要:表格驱动测试 AddDemo.go 1 // Add to number 2 func Add(a int, b int) int { 3 return a + b 4 } Add_test.go 1 import "testing" 2 // 表格驱动测试 3 func TestAdd(t *te
阅读全文
摘要:一、遍历获取 package main import ( "fmt" "os" ) func main() { fmt.Println("命令行的参数有", len(os.Args)) // 遍历 os.Args 切片,就可以得到所有的命令行输入参数值 for i, v := range os.Ar
阅读全文

浙公网安备 33010602011771号