December 2021
Intermediate to advanced
510 pages
11h 20m
English
Your application is coming along nicely. You can manage hosts on which to execute a port scan. Let’s implement the port scanning functionality now. Let’s start by adding the functionality to the scan package. After that, we’ll implement the subcommand on the command-line tool. Switch to the scan subdirectory:
| | $ cd scan |
| | $ pwd |
| | /home/ricardo/pragprog.com/rggo/cobra/pScan/scan |
Create and edit the file scanHosts.go to hold the code related to the scan functionality. Add the package definition and the import list. For this functionality, you’ll use the package fmt for formatted printing, the package net for network-related functions, and the package time to define timeouts:
Read now
Unlock full access