Log In
Join
for free
Back To Course Home
Powerful Command-Line Applications in Go
0% completed
Introduction
About the Go Language
About This Course
First Command-Line Program in Go
Building a Basic Word Counter
Testing the Basic Word Counter
Command-Line Flags
Wrapping Up
Exercise: Counting Unicode Characters
Solution: Counting Unicode Characters
Quiz: Command-Line Program in Go Preface
Interacting with Users
Defining the To-Do API
Creating the To-Do File
Creating the To-Do Test File
Creating the Initial To-Do Command-Line Tool
Testing the Initial CLI Implementation
Handling Multiple Command-Line Options
Display Command-Line Tool Usage
Improving the List Output Format
Increasing Flexibility with Environment Variables
Capturing Input from STDIN
Wrapping Up
Exercise: Delete a To-Do item
Solution: Delete a To-Do Item
Quiz: Interacting with Users
Working with Files in Go
Creating a Basic Markdown Preview Tool
Writing Tests for the Markdown Preview Tool
Adding Temporary Files to the Markdown Preview Tool
Using Interfaces to Automate Tests
Adding an Auto-Preview Feature
Cleaning Up Temporary Files
Improving the Markdown Preview Tool with Templates
Updating Functions to Improve the Markdown Preview Tool
Wrapping Up
Exercise: Working with Files
Solution: Working with Files
Quiz: Working with Files in Go
Navigating the File System
Developing a File System Crawler
Testing with Table-Driven Testing
Deleting Matched Files
Testing with the Help of Test Helpers
Logging Deleted Files
Archiving Files
Updating the Function Archiving Files
Wrapping Up
Exercise: Restoring Files and Directories
Solution: Restoring Files and Directories
Quiz: Navigating File System
Improving the Performance of CLI Tools
Introduction to colStats
Developing the Initial Version of colStats
Final Touches to the Initial Version of colStats
Writing Tests for colStats
Testing colStats
Benchmarking Our Tool
Profiling Our Tool
Reducing Memory Allocation
Improving the colStats Tool to Process Files Concurrently
Reduce Scheduling Contention
Wrapping Up
Exercise: Benchmarking Functions
Solution: Benchmarking Functions
Quiz: Improving the Performance of CLI Tools
Controlling Processes
Executing External Programs
Handling Errors
Writing Tests for Goci
Defining a Pipeline
Updating the Pipeline
Handling Output from External Programs
Running Commands with Contexts
Integration Tests with a Local Git Server
Testing Commands with Mock Resources
Handling Signals
Wrapping Up
Exercise: Capturing and Parsing Command Output
Solution: Capturing and Parsing Command Output
Quiz: Controlling Processes
Using the Cobra CLI Framework
Starting the Cobra Application
Navigating the New Cobra Application
Adding the First Subcommand to the Application
Starting the Scan Package
Creating the Subcommands to Manage Hosts
Manage the Hosts List Under the Hosts Subcommand
Testing the Manage Hosts Subcommands
Adding the Port Scanning Functionality
Testing the Port Scanning Functionality
Updating the Port Scanning Functionality
Using Viper for Configuration Management
Generating Command Completion and Documentation
Wrapping Up
Exercise: Adding and Validating Flags
Solution: Adding and Validating Flags
Quiz: Using the Cobra CLI Framework
Talking to REST API
Developing a REST API Server
Testing the REST API Server
Completing the REST API Server
Adding Finishing Touches to the REST API Server
Developing the Initial Client for the REST API
Adding Finishing Touches to the Initial Client for the REST API
Testing the Client without Connecting to the API
Viewing a Single Item
Adding an Item
Testing HTTP Requests Locally
Completing and Deleting Items
Executing Integration Tests
Wrapping Up
Exercise: Talking to REST APIs over the Internet
Solution: Talking to REST APIs over the Internet
Quiz: Talking to REST API
Developing Interactive Terminal Tools
Overview: Developing Interactive Terminal Tools
Initializing the Pomodoro Application
Storing Data with the Repository Pattern
Testing the Pomodoro Functionality
Building the Interface Widgets
Organizing the Interface’s Layout
Building the Interactive Interface
Initializing the CLI with Cobra
Wrapping Up
Exercise: Interactive Terminal Applications
Solution: Interactive Terminal Applications
Quiz: Developing Interactive Terminal Tools
Persisting Data in a SQL Database
Persisting Data in the Database
Testing the Repository with SQLite
Updating the Application to Use the SQLite Repository
Displaying a Summary to the Users
Displaying Historical Data to the Users
Wrapping Up
Exercise: Databases
Solution: Databases
Quiz: Persisting Data in a SQL Database
Distributing Tool
Starting the Notify Package
Including OS-Specific Files in the Build
Testing the Notify Package
Conditionally Building the Application
Wrapping Up
Exercise: Supporting Multiple Operating Systems
Solution: Supporting Multiple Operating Systems
Quiz: Distributing Tool
Appendix
Tracing Our Tool
Getting Started with SQLite
Go, SQL, and SQLite
Compiling the Go Application for Containers
Capturing Input from STDIN
Learn how to get input from STDIN.
We'll cover the following
Adding a feature
The io.Reader interface
Creating the getTask() function
Updating the main() function
Updating the main_test.go file
Try it yourself
Get hands-on with 1400+ tech skills courses.
Start Free Trial