Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get External IP Golang
package main
/*
URL: http://myexternalip.com/#golang
*/
import (
"io"
"net/http"
"os"
)
func main() {
resp, err := http.Get("http://myexternalip.com/raw")
if err != nil {
os.Stderr.WriteString(err.Error())
os.Stderr.WriteString("\n")
os.Exit(1)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
}
@alexandrevilain

This comment has been minimized.

Copy link

commented Jun 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.