AI-powered learning
Save this course
Write Professional Command-line Programs in Go
Gain insights into writing professional command-line programs in Go. Delve into structuring Go programs, writing idiomatic code, testing effectively, and impressing users and managers.
4.7
63 Lessons
28h 30min
Updated yesterday
Join 2.9 million developers at
Join 2.9 million developers at
LEARNING OBJECTIVES
- Identify CLI inputs/outputs: commands, flags, args, streams, piping, and exit codes
- Refactor a Go CLI into modular packages and a cmd/ structure using Go modules
- Write and run unit tests with Go testing, including table-driven and parallel tests
- Create BDD unit and end-to-end tests with Ginkgo/Gomega and generate coverage profiles
- Build structured CLIs with Cobra using root commands, subcommands, and persistent/local flags
- Implement configuration with Viper across flags, env vars, files, and remote sources with precedence
- Automate builds and releases using go build flags, GitHub Actions, Docker, and Makefiles
Learning Roadmap
1.
Overview
Overview
Learn how to use Go to build versatile and efficient command-line programs.
2.
Restructuring multi-git
Restructuring multi-git
Unpack the core of restructuring multi-git for better code organization and collaboration.
3.
Testing 1,2,3...
Testing 1,2,3...
11 Lessons
11 Lessons
Examine Go's testing capabilities, tools like Ginkgo and Gomega, and comprehensive e2e testing.
4.
Adding Smart Command-Line Parsing
Adding Smart Command-Line Parsing
13 Lessons
13 Lessons
Grasp the fundamentals of using Cobra for structured command-line applications in Go.
5.
Adding Advanced Configuration
Adding Advanced Configuration
13 Lessons
13 Lessons
Harness advanced configuration techniques in Go, using Viper and Cobra for flexible and efficient command-line programs.
6.
Adding Bells and Whistles
Adding Bells and Whistles
13 Lessons
13 Lessons
See how it works to enhance Go command-line programs with builds, linking, CI/CD, and Docker.
Certificate of Completion
Showcase your accomplishment by sharing your certificate of completion.
Complete more lessons to unlock your certificate
Show License and Attributions
Developed by MAANG Engineers
ABOUT THIS COURSE
In this course you will learn why Go is an awesome language for writing command-line programs. You will learn how to structure your Go programs, how to write idiomatic Go code, how to test your programs and how to amaze your users, peers and managers.
The focus is on command-line programs in order to keep the course down to earth, but most of the principles and best practices you will learn apply to any Go program.
ABOUT THE AUTHOR
Gigi Sayfan
I'm the DevOps team manager at Helix - a bioinformatics and genomics start-up, author of several books on Kubernetes and Go as well as hundreds of technical articles. I program professionally for 20+ years and still amazed when anything actually works.
Trusted by 2.9 million developers working at companies
A
Anthony Walker
@_webarchitect_
E
Evan Dunbar
ML Engineer
S
Software Developer
Carlos Matias La Borde
S
Souvik Kundu
Front-end Developer
V
Vinay Krishnaiah
Software Developer
Built for 10x Developers
No Passive Learning
Learn by building with project-based lessons and in-browser code editor


Personalized Roadmaps
The platform adapts to your strengths & skills gaps as you go


Future-proof Your Career
Get hands-on with in-demand skills


AI Code Mentor
Write better code with AI feedback, smart debugging, and "Ask AI"




MAANG+ Interview Prep
AI Mock Interviews simulate every technical loop at top companies


Free Resources