advent_of_code_2025/
├── day_1/
│ ├── main.go
│ ├── input.txt
│ └── README.md
├── day_2/
│ ├── main.go
│ └── input.txt
├── ...
├── utils/
│ └── file_reader.go
├── template/
│ ├── main.go
│ └── input.txt
├── go.mod
└── README.md
Each day has its own main.go file. To run a specific day:
# From the project root
cd day_1
go run .
# Or from project root in one command
cd day_1 && go run .Pros:
- Simple and straightforward
- Each day is independent
- Easy to test and debug individual solutions
- Can run multiple days in parallel in different terminals
- Natural for Advent of Code workflow
Cons:
- Need to navigate to each directory
If you prefer a central command, create a main.go in the root:
// main.go in project root
package main
import (
"fmt"
"os"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: go run . <day>")
return
}
day := os.Args[1]
cmd := exec.Command("go", "run", ".")
cmd.Dir = filepath.Join(".", fmt.Sprintf("day_%s", day))
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
}Then run with: go run . 1
-
Copy the template directory:
cp -r template day_2
-
Update the day number in the print statement
-
Add your puzzle input to
input.txt -
Implement your solution
The utils package contains common functions:
ReadFileLines(filename string) []string- Reads file lines into a string slice
Add more utilities as needed for:
- Number parsing
- Grid operations
- Graph algorithms
- etc.
- Input Files: Always name them
input.txtfor consistency - Testing: Consider adding
_test.gofiles for complex solutions - Benchmarking: Use Go's built-in benchmarking for optimization challenges
- Part 2: Structure your code to easily extend for part 2
# From project root
cp -r template day_X
cd day_X
# Paste your input into input.txt
go run .