docs: document and add blog post about go tool task (#2791)

This commit is contained in:
Andrey Nering
2026-04-14 22:47:45 -03:00
committed by GitHub
parent d61d92dfdf
commit 8fe3d048fa
4 changed files with 88 additions and 4 deletions

View File

@@ -211,7 +211,11 @@ export default defineConfig({
collapsed: false,
items: [
{
text: 'New `if:` Control and Variable Prompt',
text: 'go tool task',
link: '/blog/go-tool-task'
},
{
text: 'New "if:" Control and Variable Prompt',
link: '/blog/if-and-variable-prompt'
}
]

View File

@@ -0,0 +1,53 @@
---
title: go tool task
description: How to use Task using go tool.
author: andreynering
date: 2026-04-14
outline: deep
editLink: false
---
# `go tool task`
<AuthorCard :author="$frontmatter.author" />
Do you know that you can use Task without really needing to install it?
If you work with Go, you probably depend on external binaries like linters,
code generators and... Task.
But asking your coworkers or contributors to install dependencies can be messy.
Everyone is on a different operating system, use a different package manager,
etc. In fact, [Task supports several package managers][install], but even having
to choose how you want to install it can lead to some fatigue.
Well, turns out you can just use `go tool`!
Step one: add Task as a tool to your Go project:
```bash
go get -tool github.com/go-task/task/v3/cmd/task@latest
```
The command above will add a line like this to your `go.mod`:
```
tool github.com/go-task/task/v3/cmd/task
```
Step two: prefix `go tool` when calling Task:
```bash
go tool task {arguments...}
```
That's all!
Go will compile the specified Task version on demand when calling `go tool task`.
Don't worry, Go caches the tool, so subsequent calls are faster.
This is useful when running Task on CI, as you don't need to stress about having
to install it. It also means it'll be pinned to a specific Task version (but
Dependabot or Renovate should be able to update it for you).
[install]: https://taskfile.dev/docs/installation

View File

@@ -5,7 +5,16 @@ editLink: false
---
<BlogPost
title="New `if:` Control and Variable Prompt"
title="go tool task"
url="/blog/go-tool-task"
date="2026-04-14"
author="andreynering"
description='How to use Task using "go tool".'
:tags="['installation']"
/>
<BlogPost
title='New "if:" Control and Variable Prompt'
url="/blog/if-and-variable-prompt"
date="2026-01-24"
author="vmaerten"

View File

@@ -320,8 +320,6 @@ examples and configuration.
## Build From Source
### Go Modules
Ensure that you have a supported version of [Go](https://golang.org) properly
installed and setup. You can find the minimum required version of Go in the
[go.mod](https://github.com/go-task/task/blob/main/go.mod#L3) file.
@@ -346,6 +344,26 @@ released binary.
:::
## Go Tool
If you're working in a Go project, a nice possibility is using `go tool`.
`go tool` makes it easy to run Task without needing to install the binary
manually. This works well on CI.
To do that, just run the following to add Task as a tool in your Go project.
Task will be added to your `go.mod`.
```bash
go get -tool github.com/go-task/task/v3/cmd/task@latest
```
Then, prefix `go tool` when calling Task like below. Go will compile Task on
demand before calling it.
```bash
go tool task {arguments...}
```
## Setup completions
Some installation methods will automatically install completions too, but if