gogeo

package module
v0.0.0-...-59b5dca Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

README

gogeo library

Build Status Go Report Card GoDoc Coverage Status

License Apache 2.0

Contains the list of countries and continents and some additional information. In the package, you can find also data type Code2 which can work properly as a JSON field and SQL data type.

Documentation

Index

Constants

View Source
const (
	UndefinedCountryCodeISO2 = "**"
	UndefinedCountryCodeISO3 = "***"
)

undefined country codes

Variables

View Source
var (
	ErrCode2InvalidScanType  = errors.New("[gogeo.code2] invalid scan type, supports only bytes and string")
	ErrCode2InvalidValueSize = errors.New("[gogeo.code2] invalid value size, supports only two 2 chars")
)

Error list...

View Source
var Continents = []Continent{
	{ID: 1, Code2: "EU", Name: "Europe"},
	{ID: 2, Code2: "AS", Name: "Asia"},
	{ID: 3, Code2: "AF", Name: "Africa"},
	{ID: 4, Code2: "OC", Name: "Oceania"},
	{ID: 5, Code2: "SA", Name: "South America"},
	{ID: 6, Code2: "NA", Name: "North America"},
	{ID: 7, Code2: "AN", Name: "Antarctica"},
}

Continents list

View Source
var Countries = []Country{}/* 255 elements not displayed */

Countries list

UndefinedCountryCode2 for undefined codename

Functions

This section is empty.

Types

type Code2

type Code2 [2]byte

Code2 implements basic

func CountryCode2ByString

func CountryCode2ByString(code string) Code2

CountryCode2ByString returns code by string code ISO-2 or ISO-3

func (Code2) ISO2

func (cc Code2) ISO2() string

ISO2 returns the string code with two simbols

func (Code2) ISO3

func (cc Code2) ISO3() string

ISO3 returns the string code with three simbols

func (Code2) MarshalJSON

func (cc Code2) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*Code2) Scan

func (cc *Code2) Scan(data interface{}) error

Scan implementation of sql.Scanner interface

func (Code2) String

func (cc Code2) String() string

func (*Code2) UnmarshalJSON

func (cc *Code2) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

func (Code2) Value

func (cc Code2) Value() (driver.Value, error)

Value implementation of sql driver.Valuer interface

type Continent

type Continent struct {
	ID    int
	Code2 string
	Name  string
}

Continent description

type Coordinates

type Coordinates struct {
	Lat, Lon float64
}

Coordinates object

type Country

type Country struct {
	ID          int         `json:"id"`
	Code2       string      `json:"cc,omitempty"`
	Code3       string      `json:"ccc,omitempty"`
	Name        string      `json:"name,omitempty"`
	ShortName   string      `json:"short,omitempty"`
	Native      string      `json:"native,omitempty"`
	Continent   string      `json:"continent,omitempty"`
	Capital     string      `json:"capital,omitempty"`
	Currency    []string    `json:"currency,omitempty"`
	Languages   []string    `json:"langs,omitempty"`
	Phones      []string    `json:"phones,omitempty"`
	Coordinates Coordinates `json:"corrd,omitempty"`
	TimeZones   []TimeZone  `json:"zones,omitempty"`
}

Country info

func CountryByCode2

func CountryByCode2(code string) *Country

CountryByCode2 object

func CountryByCode3

func CountryByCode3(code string) *Country

CountryByCode3 object

type TimeZone

type TimeZone struct {
	ZoneName string
	Lon      float64
}

TimeZone object

Jump to

Keyboard shortcuts

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