ipinfo

package module
v0.0.0-...-a3270d9 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 3 Imported by: 6

README

Looking for new repo maintainer! please open an issue to condidate!

ipinfo

A wrapper for http://ipinfo.io written in Go language

package main

import (
	"log"
	"net"

	"github.com/RevH/ipinfo"
)

func main() {
	myIP, err := ipinfo.MyIP()
	if err != nil {
		log.Fatalln(err)
	}
	log.Println(myIP)

	foreignIP, err := ipinfo.ForeignIP("8.8.8.8")
	if err != nil {
		log.Fatalln(err)
	}
	log.Println(foreignIP)
}

Documentation

Overview

Package ipinfo provides info on IP address location using the http://ipinfo.io service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPInfo

type IPInfo struct {
	IP       string `json:"ip"`
	Hostname string `json:"hostname"`
	City     string `json:"city"`
	Region   string `json:"region"`
	Country  string `json:"country"`
	Loc      string `json:"loc"`
	Org      string `json:"org"`
	Postal   string `json:"postal"`
}

IPInfo wraps json response

func ForeignIP

func ForeignIP(ip string) (*IPInfo, error)

ForeignIP provides information about the given IP address (IPv4 or IPv6)

func MyIP

func MyIP() (*IPInfo, error)

MyIP provides information about the public IP address of the client.

Jump to

Keyboard shortcuts

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