Taskfile demo

https://github.com/yangyang5214/blog/issues/1

makefile 很好用,但是有些语法我不会。 go-task yml & shell 不错,推荐

Taskfile.yml

https://github.com/go-task/task/blob/main/.golangci.yml

yaml 复制代码
# go install github.com/go-task/task/v3/cmd/task@latest
version: '3'

vars:
  APPS: { sh: find app -maxdepth 1 -mindepth 1 -type d -print | xargs -L 1 }
  MODULE_NAME: { sh: go list -m }

tasks:
  desc: init go mod
  init:
    cmds:
      - go get -u google.golang.org/protobuf/cmd/protoc-gen-go
      - go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc
      - go get -u github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2
      - go get -u github.com/google/wire/cmd/wire
      - go get -u github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
      - go get -u github.com/envoyproxy/protoc-gen-validate
      - go get -u github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2
      - go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
      - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
      - go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
      - go install github.com/envoyproxy/protoc-gen-validate@latest
      - go install github.com/google/wire/cmd/wire@latest

  format:
    desc: Format *go code
    vars:
      GO_FILES: "find . ! -path './vendor/*' -type f -name '*.go'"
    cmds:
      - ({{.GO_FILES}} | xargs gofmt -s -w)
      - ({{.GO_FILES}} | xargs gci write --section Standard --section Default --section "Prefix({{.MODULE_NAME}})")
      - ({{.GO_FILES}} | xargs golines -w --max-len=180 --reformat-tags --shorten-comments --ignore-generated)
      - go mod edit -fmt

  wire:
    desc: Run wire cmd for apps
    cmds:
      - for: { var: APPS, as: APP }
        cmd: cd {{.APP}} && wire ./... && cd -
      - task format

  mod:
    desc: Downloads and tidy Go modules
    cmds:
      - go mod download
      - go mod tidy

  lint:
    desc: Run golangci-lint
    sources:
      - './**/*.go'
      - .golangci.yml
    cmds:
      - golangci-lint run

add zsh completion

https://github.com/sawadashota/go-task-completions

Clone the repository inside your oh-my-zsh repo:

git clone https://github.com/sawadashota/go-task-completions.git ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/task

Enable it in your .zshrc by adding it to your plugin list and reloading the completion:

# ... 是之前已经存在的 plugin 
# 例如我的修改为 plugins=(git task)
plugins=(... task)
autoload -U compinit && compinit

Reference

https://github.com/go-task/task/issues/103 Add Bash, ZSH and Windows command line completion #103

相关推荐
郝同学的测开笔记1 天前
云原生探索系列(十二):Go 语言接口详解
后端·云原生·go
一点一木2 天前
WebAssembly:Go 如何优化前端性能
前端·go·webassembly
千羽的编程时光2 天前
【CloudWeGo】字节跳动 Golang 微服务框架 Hertz 集成 Gorm-Gen 实战
go
27669582924 天前
阿里1688 阿里滑块 231滑块 x5sec分析
java·python·go·验证码·1688·阿里滑块·231滑块
Moment5 天前
在 NodeJs 中如何通过子进程与 Golang 进行 IPC 通信 🙄🙄🙄
前端·后端·go
唐僧洗头爱飘柔95275 天前
(Go基础)变量与常量?字面量与变量的较量!
开发语言·后端·golang·go·go语言初上手
黑心萝卜三条杠5 天前
【Go语言】深入理解Go语言:并发、内存管理和垃圾回收
google·程序员·go
不喝水的鱼儿6 天前
【LuatOS】基于WebSocket的同步请求框架
网络·websocket·网络协议·go·luatos·lua5.4
微刻时光6 天前
程序员开发速查表
java·开发语言·python·docker·go·php·编程语言
lidenger6 天前
服务认证-来者何人
后端·go