Skip to content

Instantly share code, notes, and snippets.

@thecloudranger
Last active June 12, 2024 06:36
Show Gist options
  • Select an option

  • Save thecloudranger/35cc523e1df1e1de3ed8dde46d601a6b to your computer and use it in GitHub Desktop.

Select an option

Save thecloudranger/35cc523e1df1e1de3ed8dde46d601a6b to your computer and use it in GitHub Desktop.
Go dev environment for learning

Overview

This is a gist for setting up a fresh learning environment to learn Go programming. Primary tools used:

  1. Docker
  2. VS Code
  3. VS Code extensions - Go, Remote Development, Docker
  4. Go runtime

Docker setup

Since Docker Desktop changed their license for usage there has been a surge in adopting alternatives such as Collima, Podman Desktop, Rancher Desktop, Finch etc.

Colima

brew install colima docker docker-compose docker-credential-helper
colima start --cpu 2 --memory 4

VS code setup

Curently exploring devpod.sh with Colima

Project setup

Beginning project directory can look like this:

<project name>
|- .devcontainer/
|  |- devcontainer.json
|- .gitignore
|- hello-world.go
|- README.md

A structured Go project directory without modules should look like below:

<project name>
|- .devcontainer/
|  |- Dockerfile
|  |- devcontainer.json
|- cmd/ # subdirectories for each CLI command being built.
|- docs/
|- pkg/ # non-main packages
|- .gitignore
|- Makefile
|- README.md

devcontainer.json

{
  "name": "Go",
  "image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm"
  // Or use the universal image from AWS used in codecatalyst. More info: https://docs.aws.amazon.com/codecatalyst/latest/userguide/devenvironment-universal-image.html
  //"image": "public.ecr.aws/aws-mde/universal-image:3.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment