goeip

package module
v0.0.0-...-8db6ede Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 4 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

goeip

Single file library for Kealper's geoip utility written in Golang without extra dependencies

Installing

go get github.com/JoshuaDoes/goeip

Example

package main

import "fmt"
import "github.com/JoshuaDoes/goeip"

func main() {
	result, err := goeip.Lookup("joshuadoes.com")
	if err != nil {
		fmt.Println("Error: " + fmt.Sprintf("%v", err))
		return
	}
	if result.Error > 0 {
		fmt.Println("Lookup error: " + result.Details)
	}

	fmt.Println("City: " + result.City)
	fmt.Println("State: " + result.State)
}
Output
> go run main.go
City: Dallas
State: Texas

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASN

type ASN struct {
	Number       int
	Organization string
}

ASN holds data about an ASN

type Country

type Country struct {
	Name string `json:"Name"`
	Code string
}

Country holds data about a country

type Location

type Location struct {
	Latitude  float64
	Longitude float64
}

Location holds data about a location

type Result

type Result struct {
	Error      int
	Details    string `json:"Detail"`
	IPAddr     string
	Hostname   string
	City       string
	State      string
	PostalCode string
	Country    Country
	Timezone   string
	Location   Location
	ASN        ASN
}

Result holds data returned by the API

func Lookup

func Lookup(host string) (*Result, error)

Lookup performs a GET request to the API and returns data about the specified hostname/ipaddr

Jump to

Keyboard shortcuts

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