StoreBackEnd/pkg/utils/Network.go

32 lines
550 B
Go

package utils
import (
"fmt"
"net"
"strings"
)
// NetworkLister List all network interface available
func NetworkLister() {
// Retrieve Interfaces
inter, err := net.Interfaces()
// Process errors
if err != nil {
println("[ERROR] An error occurred : " + err.Error())
return
}
// Display items
println("\n\nNetwork interface list :")
for i, val := range inter {
fmt.Printf("%d. %s\n", i, val.Name)
}
print("\n")
}
// IsIPv4 Check if the ip is a v4 or v6 ip
func IsIPv4(addr string) bool {
return strings.Count(addr, ":") < 2
}