Skip to content

Instantly share code, notes, and snippets.

@nick-fedesna
Created June 12, 2014 04:10
Show Gist options
  • Save nick-fedesna/47e3e6d6176b13a55ce6 to your computer and use it in GitHub Desktop.
Save nick-fedesna/47e3e6d6176b13a55ce6 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net"
"os"
)
func main() {
name, err := os.Hostname()
if err != nil {
fmt.Printf("Oops: %v\n", err)
return
}
addrs, err := net.LookupHost(name)
if err != nil {
fmt.Printf("Oops: %v\n", err)
return
}
for _, a := range addrs {
fmt.Println(a)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment