// Check Args
if len(os.Args) != 2 {
fmt.Println("Usage xxx <arg1> <arg2>")
return
}
arg1 := os.Args[1]
arg1 := os.Args[2]
[......]
// Check Args
if len(os.Args) != 2 {
fmt.Println("Usage xxx <arg1> <arg2>")
return
}
arg1 := os.Args[1]
arg1 := os.Args[2]
[......]
可以使用go proxy:https://goproxy.io/zh/
export GO111MODULE=on
export GOPROXY=https://goproxy.io,direct
然后执行go get
go mod init github.com/my/repo
go get github.com/go-redis/redis/v8
[......]
// 获取当前工作目录
wdPath, err := os.Getwd()
if err != nil {
panic(err)
}
// 路径join
vDir := path.Join(wdPath, "path1", "path2")
// 创建目录
os.Mkdir(vDir, os.ModePerm)
[......]
Stream + Copy流
func downloadFile(url string, path string) {
defer wg.Done()
// Get the data
resp, err := http.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
// Create output file
out, err := os.Create([......]
Run -> Add Configuration -> Launch file,生成launch.json
添加参数
"externalConsole": true,
"args": ["-n","../../test.text"]
[......]