Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/polera/publicip

Go pkg for returning your public facing IP address.
https://github.com/polera/publicip

Last synced: 24 days ago
JSON representation

Go pkg for returning your public facing IP address.

Lists

README

        

#publicip

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

[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg)](http://godoc.org/github.com/polera/publicip) [![License](http://img.shields.io/badge/license-mit-blue.svg)](https://raw.githubusercontent.com/polera/publicip/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/polera/publicip)](https://goreportcard.com/report/github.com/polera/publicip) [![codecov](https://codecov.io/gh/polera/publicip/branch/master/graph/badge.svg)](https://codecov.io/gh/polera/publicip)

Author
==
James Polera

Dependencies
==
publicip uses Glide for dependency management. After cloning this package, run:
```bash
glide up
```

Credits
==
This package was inspired by both:

[public-ip (nodejs)](https://github.com/sindresorhus/public-ip/blob/master/index.js)

[OpenDNS::MyIP (Perl)](https://metacpan.org/pod/OpenDNS::MyIP)

Example
==
```go
package main

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

func main() {

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

}

```