publicip

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 2 Imported by: 0

README

#publicip

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

GoDoc License Go Report Card codecov

Changes

Removed output to a log directly from this package (Dmitriy Kuznetsov dmitriy.v.kuznetsov@gmail.com).

Author of the original package

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/dikman/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)
  }

}

Documentation

Overview

Package publicip returns the public facing IPv4 address of the requesting client by querying servers at OpenDNS.

Example:

package main

import (
"fmt"
"github.com/dikman/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\n", myIpAddr)
}

}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIP

func GetIP() (string, error)

GetIP returns the public facing IPv4 address of the requesting client by querying servers at OpenDNS.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL