geolocation

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 23, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Status         string  `json:"status,omitempty" meridian:"disable"`
	Message        string  `json:"message,omitempty" meridian:"disable"`
	Continent      string  `json:"continent,omitempty" description:"Full name of continent" ex:"North America"`
	ContinentCode  string  `json:"continentCode,omitempty" description:"Shorthand name of continent" ex:"NA"`
	Country        string  `json:"country,omitempty" description:"Full name of country" ex:"United States"`
	CountryCode    string  `json:"countryCode,omitempty" description:"Shorthand name of country" ex:"US"`
	Region         string  `json:"region,omitempty" description:"Shorthand name of region, state, etc." ex:"CA"`
	RegionName     string  `json:"regionName,omitempty" description:"Full name of region, state, etc." ex:"California"`
	City           string  `json:"city,omitempty" description:"Full name of city" ex:"San Francisco"`
	District       string  `json:"district,omitempty" description:"Full name of city district" ex:"South of Market"`
	ZIP            string  `json:"zip,omitempty" description:"Postal code" ex:"94103"`
	Latitude       float64 `json:"lat"`
	Longitude      float64 `json:"lon"`
	Timezone       string  `json:"timezone,omitempty" description:"tzdata name of timezone" ex:"America/Los_Angeles"`
	TimezoneOffset int     `json:"offset" description:"Offset in seconds from UTC" ex:"-28800 for America/Los_Angeles"`
	ISP            string  `json:"isp,omitempty" description:"Name of ISP" ex:"Comcast Cable Communications, LLC"`
	ORG            string  `json:"org,omitempty" description:"Organizational owner of IP, usually ISP" ex:"Comcast Cable Communications, Inc"`
	ASN            string  `json:"as,omitempty" description:"AS name and number for current IP" ex:"AS7922 Comcast Cable Communications, LLC"`
	Mobile         bool    `json:"mobile" description:"Whether or not you are on a mobile network"`
	Proxy          bool    `json:"proxy" description:"Whether or not you are using a proxy"`
	IP             string  `json:"query,omitempty" description:"Current IP address" ex:"0.0.0.0"`
}

Info stores location query results.

func (*Info) New

func (i *Info) New(location ...string) error

New takes an optional location (IP address or domain name) and returns geolocation information about the location.

func (*Info) String

func (i *Info) String() string

func (*Info) ToDescription

func (i *Info) ToDescription() string

ToDescription returns a formatted description of all fields in the Info struct.

func (*Info) ToJSON

func (i *Info) ToJSON(fields ...string) ([]byte, error)

ToJSON takes a list of fields to convert to JSON byte array from a Info struct and returns the byte array with only those fields (unless the All specifier is given), regardless of whether or not the fields are set in the Info struct.

func (*Info) ToString

func (i *Info) ToString(fields ...string) string

ToString returns a formatted string representation of the Info struct. The optional fields argument takes a list of fields to output. Giving no arguments will output an empty string. Specifying "All" will return all fields.

func (*Info) ValidateFields

func (i *Info) ValidateFields(fields ...string) error

ValidateFields validates that the given field names exist within the given Info object.

Jump to

Keyboard shortcuts

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