Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

countries

Go package to retrieve country data by the ISO 3166-1 alpha-2 code.


Build & Tests

Install

go get github.com/RobinToubi/countries

Use

Continent name by country code

func GetContinentByCountry(countryCode string) string, error

Continent name To Country code list

func GetCountryCodesByContinent(continent string) []string

Simple example

package main

import (
	"fmt"
	"github.com/RobinToubi/countries"
)

func main() {
	// Instantiate the service
	countryService := countries.InstanceCountry()
	
	// Retrieve a continent by the country code
	continent, _ := countryService.GetContinentByCountry("HK")
	fmt.Println(continent) // "Asia"
	
	// Retrieve country codes by a continent name
	cCodes, _ := countryService.GetCountryCodesByContinent("Asia")
	fmt.Println(cCodes) // [AF AM AZ BH BD BT BN KH CN CX CC CY GE HK IN ID IR IQ IL JP JO KZ KP KR KW KG LA LB MY MV MN MM NP OM PK PH QA RU SA SG LK SY TW TJ TH TR TM AE UZ VN YE]
}

About

Go package to retrieve country data by the ISO 3166-1 alpha-2 code.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages