Solution: Adding and Validating Flags
See the solution to adding a new flag to the pScan scan subcommand.
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 add. Some valid values in a bool map, called validValues
, are defined. Finally, we check if a valid filter value has been passed. If not, we throw an error message and leave the function.
Get hands-on with 1400+ tech skills courses.