Matching IPv4 addresses

An IPv4 address, or simply an IP address, has four discrete parts. As an IPv4 address is stored using 8-bit binary numbers, each part can have values from 0, which is 00000000 in the binary format, to 255, which is equal to 11111111 in the binary format.

The format of an IPv6 address is much more complicated than the format of an IPv4 address so the presented program will not work with IPv6 addresses.

The name of the program will be findIPv4.go and it is going to be presented in five parts. The first part of findIPv4.go is shown here:

package main 
 
import ( 
    "bufio" 
    "fmt" 
    "io" 
    "net" 
    "os" 
    "path/filepath" 
    "regexp" 
) 

As findIPv4.go is a pretty sophisticated utility, it needs many standard Go packages.

The second part ...

Get Mastering Go - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.