Golang Environment Setup

Diego Orozco by Diego Orozco on April 6, 2025

Using Devbox to set up your Go development environment is a great way to keep everything isolated without needing to install Go globally on your system.

Step 1: Initialize Devbox

If you haven’t already initialized Devbox in your project folder, run:

devbox init

This will create a devbox.json file in your current directory.

Step 2: Add Go to Your Devbox Configuration

Edit the generated devbox.json file to include Go. Here’s an example configuration that installs Go 1.24.1:

{
    "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
    "packages": [
      "go@1.24.1"
    ],
    "shell": {
      "init_hook": [
        "echo 'Welcome to devbox!' > /dev/null"
      ],
      "scripts": {
        "test": [
          "echo \"Error: no test specified\" && exit 1"
        ]
      }
    }
  }
  

If you want to install Go’s latest version, simply use go@latest

Step 3: Enter the Devbox Shel

Once your devbox.json is ready, run:

devbox shell

Devbox will install the specified Go version and make it available in your shell.

You’re now ready to develop with Go in an isolated environment — no global installations needed! 🚀

<< Generics | Golang Basics - Project Structure >>