CLI Task Manager with JSON Persistence
Build a to-do list manager for the terminal in Go. You type commands like tasks add "Buy milk", tasks list, tasks done 2 and tasks delete 3, and your tasks are saved in a JSON file, so they're still there next time. The list shows each task's number, whether it's done and when it was added, and you can filter to see only open tasks. It's a great first Go project: you'll learn structs and slices, reading and writing JSON with encoding/json, working with files, building subcommands with the flag package, returning and handling errors the Go way, and writing table-driven tests.
- Estimate
- ~6h
- Steps
- 5
- Completed by
- 0
- Proposed by
- codeseed.app
Go standard library · encoding/json
Project roadmap
- 01
Set up the project
~0.5hRun go mod init and create main.go. Define a Task struct with ID, Title, Done and CreatedAt fields, with JSON tags such as `json:"title"`. Print a usage message listing the commands when the program runs without arguments. Done when: go run . prints the usage.
- 02
Save and load tasks
~1.5hWrite Load(path) and Save(path, tasks) functions using encoding/json. When the file doesn't exist, start with an empty list. Save by writing to a temporary file and renaming it, so a crash never leaves a broken file. Return errors with context using fmt.Errorf and %w. Done when: tasks saved by one run are loaded by the next.
- 03
Add the main commands
~1.5hRead the command from os.Args and create a flag.FlagSet for each: add TITLE (IDs keep increasing, even after deletes), list (with an --all flag to include done tasks, open tasks only by default) and done ID. Print the list as aligned columns with text/tabwriter, such as 2 [ ] Buy milk (added 3 Mar). Done when: tasks can be added, listed and completed.
- 04
Add delete and validation
~1hAdd delete ID and clear-done. Validate input: an empty title, an ID that isn't a number, and an ID that doesn't exist each print a clear message to stderr and exit with code 1, without changing the file. Done when: every invalid command prints a helpful message and leaves the tasks unchanged.
- 05
Write tests
~1.5hMove the task logic into functions that don't touch os.Args or the terminal, and write table-driven tests: adding, completing, deleting, ID numbering after deletes, and invalid IDs. Test Load and Save with t.TempDir(): a missing file, an empty file, a corrupted file, and a save then load giving the same tasks. Done when: go test ./... passes.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack