Starting the Scan Package
Learn how to add the port scanning functionality.
We have the skeleton of our application ready, so let’s add the port scanning
functionality, starting with the hosts list management. For this tool, we’ll create a separate package scan
to develop the business logic.
Creating the hostsList.go
file
Now, we create and edit the file hostsList.go
. We start by defining the package
name scan
and the import
list.
For this package, we’ll use the following packages:
bufio
to read data from files.errors
to define error values.fmt
to print formatted output.io/ioutil
to write data to files.os
for operating system-related functions.sort
to sort the hosts list content.
Get hands-on with 1400+ tech skills courses.