opendnsmyip: A Go package to return the public-facing IPv4 address of the client (by querying the Cisco OpenDNS servers).

James Polera 298c644ed7 Update README.md 7 years ago
.gitignore 76715630b9 Initial commit. 7 years ago
LICENSE 47578b0317 Added LICENSE 7 years ago
README.md 298c644ed7 Update README.md 7 years ago
glide.lock 76715630b9 Initial commit. 7 years ago
glide.yaml 76715630b9 Initial commit. 7 years ago
publicip.go 76715630b9 Initial commit. 7 years ago
publicip_test.go 76715630b9 Initial commit. 7 years ago

README.md

#publicip

This package returns the public facing IP address of the calling client (a la https://icanhazip.com, but from Go!)

Author

James Polera james@uncryptic.com

Dependencies

publicip uses Glide for dependency management. After cloning this package, run:

glide up

Credits

This package was inspired by both:

public-ip (nodejs)

OpenDNS::MyIP (Perl)

Example

package main

import (
  "fmt"
  "github.com/polera/publicip"
)

func main() {

  myIpAddr, err := publicip.GetIP()
  if err != nil {
    fmt.Printf("Error getting IP address: %s", err)
  } else {
    fmt.Printf("Public IP address is: %s", myIpAddr)
  }

}