---
title: "Go"
description: "Deploy Go applications on Miget as statically-linked binaries."
---
Miget Buildpacks automatically detect and build your Go applications when you select **Auto detection (Miget Buildpacks)** as the build method. Your application is compiled into a statically-linked binary for maximum portability. For the full reference, visit the [migetpacks Go documentation](https://migetpacks.com/languages/go).
## Detection
Your application is detected as Go when the following file is present in the root directory:
- `go.mod`
## Version Detection
The Go version is determined from the `go` directive in your `go.mod` file. For example:
```
go 1.22
```
If no version is specified, a recent stable Go version is used.
## Build Process
During the build, the following steps are performed:
1. **Static binary compilation** - Your application is compiled with `CGO_ENABLED=0`, producing a fully static binary.
2. **Module name detection** - The module name is auto-detected from `go.mod`.
3. **Package spec** - To build specific packages, add a `+heroku install` comment in your `go.mod`:
```
// +heroku install ./cmd/myapp
```
4. **Build hooks** - You can run custom scripts before or after compilation by including `bin/pre_compile` or `bin/post_compile` in your repository.
5. **golang-migrate** - If your project uses `golang-migrate`, it is auto-detected and included in the final image.
## Run Command
The compiled binary is used as the run command. The binary name is derived from your module name.
You can also override the run command directly in the Miget dashboard when creating your app or changing the deployment source.
## Configuration
You can customize the build and runtime behavior through the Miget dashboard and repository configuration files:
- **Environment variables** - Set under **Settings -> Variables** in the Miget dashboard
- **Procfile** - Define the start command at the root of your repository
- **app.json** - Application manifest for additional configuration
- **Project Path** - For monorepo setups, specify the subdirectory containing your application code in the **Advanced** tab
- **Pre-Deploy Command** - Run a command before deployment (e.g., database migrations) in the **Advanced** tab
- **Post-Deploy Command** - Run a command after successful deployment (e.g., seeding data, cache warming) in the **Advanced** tab
## Docker Hardened Images
You can enable Docker Hardened Images (DHI) in the **Advanced** tab when creating your app or changing the deployment source. When enabled, your application is built using distroless runtime images with a minimal attack surface, no shell, and no package manager.
DHI requires Go 1.22 or later.
For the complete reference, see the [migetpacks Go documentation](https://migetpacks.com/languages/go).