cspc

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 4 Imported by: 0

README

cspc

Go-centric Country, States, Province, County etc. information including lookup table DDL/DML for PostgreSQL

Please feel free to create issues to add to this library. This is US-Canada centric to start as that is the use case I am solving for currently, but can/should be expanded.

If you use one of the JSON array constants, know that all countries, states, provinces, counties ordering is by name.

Documentation

Index

Constants

View Source
const CountryAlpha2CodeJSON string = `` /* 1216-byte string literal not displayed */

CountryAlpha2CodeJSON string is a JSON string with all country ISO 3166-1 Alpha 2 Code in JSON format, in alphabetical order

View Source
const CountryFullJSON string = `` /* 39604-byte string literal not displayed */

CountryFullJSON string is a JSON string with all country information in JSON format, ordered by country_name

View Source
const CountryNamesJSON string = `` /* 3383-byte string literal not displayed */

CountryNamesJSON string is a JSON string with all country names in JSON format, in alphabetical order

View Source
const USCountyJSON string = `` /* 176307-byte string literal not displayed */

USCountyJSON is a list of all US Counties using their FIPS code

View Source
const USStatesCodeJSON string = `` /* 261-byte string literal not displayed */

USStatesCodeJSON is the JSON array for all US State Codes (including DC and Puerto Rico) in alpha order by name

View Source
const USStatesJSON string = `` /* 7059-byte string literal not displayed */

USStatesJSON is the JSON array for all US States (including DC and Puerto Rico)

View Source
const USStatesNameJSON string = `` /* 610-byte string literal not displayed */

USStatesNameJSON is the JSON array for all US State Names (including DC and Puerto Rico) in alpha order by name

Variables

This section is empty.

Functions

func Alpha2s

func Alpha2s() []string

Alpha2s returns a slice of strings containing the ISO 3166-1 Alpha 2 Codes in order by Country Name

func FindUSCountyCodes

func FindUSCountyCodes(sp StateProvince) ([]string, error)

FindUSCountyCodes returns a list of County Codes for a US State

func FindUSCountyNames

func FindUSCountyNames(sp StateProvince) ([]string, error)

FindUSCountyNames returns a list of County Names for a US State

func Names

func Names() []string

Names returns a slice of strings containing the Country names in order by Country Name

Types

type Country

type Country struct {
	ID               uuid.UUID
	Name             string `json:"country_name"`
	Alpha2Code       string `json:"country_alpha_2_cd"`
	Alpha3Code       string `json:"country_alpha_3_cd"`
	UNM49Code        int    `json:"country_un_m49_cd"`
	LatitudeAverage  string `json:"latitude_average"`
	LongitudeAverage string `json:"longitude_average"`
	States           []StateProvince
	CreateUsername   string
	CreateTimestamp  time.Time
	UpdateUsername   string
	UpdateTimestamp  time.Time
}

Country represents a nation with its own government, occupying a particular territory.

func FindCountryInJSONByAlpha2Code

func FindCountryInJSONByAlpha2Code(alpha2code string) (*Country, error)

FindCountryInJSONByAlpha2Code initializes a Country struct using the CountryFullJSON constant (instead of going to the database). If the Country is the United States, the US states will be added as well.

func (Country) FindStateByCode

func (c Country) FindStateByCode(stateCode string) (StateProvince, error)

FindStateByCode returns a State/Province for a country given it's State or Province code

type County

type County struct {
	ID               uuid.UUID
	Code             string `json:"county_cd"`
	Name             string `json:"county_name"`
	LatitudeAverage  string `json:"latitude_average"`
	LongitudeAverage string `json:"longitude_average"`
	CreateUsername   string
	CreateTimestamp  time.Time
	UpdateUsername   string
	UpdateTimestamp  time.Time
}

County is a geographical region of a country used for administrative or other purposes, in certain modern nations. For the US, the Code is the Federal Information Processing System (FIPS) Codes for States and Counties. FIPS codes are numbers which uniquely identify geographic areas.

func FindUSCounties

func FindUSCounties(sp StateProvince) ([]County, error)

FindUSCounties returns a list of Counties for a US State

type StateProvince

type StateProvince struct {
	ID               uuid.UUID
	Code             string `json:"state_prov_cd"`
	Name             string `json:"state_name"`
	FIPSCode         string `json:"state_fips_cd"`
	LatitudeAverage  string `json:"latitude_average"`
	LongitudeAverage string `json:"longitude_average"`
	Counties         []County
	CreateUsername   string
	CreateTimestamp  time.Time
	UpdateUsername   string
	UpdateTimestamp  time.Time
}

StateProvince is a State or Province of a Country that makes up a particular territory

func USStates

func USStates() ([]StateProvince, error)

USStates returns all US States

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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