Search⌘ K
AI Features

Solution: Adding and Validating Flags

Explore how to add and validate flags in a Go CLI tool using the Cobra framework. Understand the use of a validation map, error handling for invalid inputs, and modifying output based on user-defined filters. This lesson helps you ensure your CLI applications handle flags correctly and improve user interaction through proper input checks and results filtering.

We'll cover the following...

Solution explanation

In the scan.go file, we run a preRunE function that specifies a new filter that the user can ...