Go Lang Create Taskfile

Created At: 2023-04-25 20:55:18 Updated At: 2023-04-26 06:41:17

Here we will learn how to create a Taskfile in GoLang. The benefit of Taskfile is that you don't have to write a long command to run your Go lang app. 

To create a Taskfile tool make sure you have installed Taskfile for your OS. 

To install the the tool you run the command

brew install go-task/tap/go-task

Then you can do your Taskfile

version: '3'
tasks:
  build:
    cmds:
      - go build -o app cmd/service/main.go

  test:
    cmds:
      - go test -v ./...
  
  lints:
    cmds:
      - golangci-lint run
  
  run:
    cmds:
      - docker-compose up --build

You see from the file, right after every file we put cmds. It contains the actual commands. In my case, my main.go file is in the cmd/service folder.

Now I can simply run task run and it will build my project.

 

Comment

Add Reviews

Recommended Posts

Latest Posts

Subscribe our newsletter