Is there an easy API in Go to figure out whether a given IP address / hostname belongs to the local machine?
Asked
Active
Viewed 262 times
0
-
You will have to [enumerate all network interfaces](https://golang.org/pkg/net/#Interfaces) and their addresses and compare them to the address in question. [os.Hostname](https://golang.org/pkg/os/#Hostname) returns the hostname. – Peter Jul 05 '20 at 10:54
-
maybe this answer help https://stackoverflow.com/a/50825191/2126159 – Diako Amir Jul 05 '20 at 11:49