iso3166

package module
v0.0.0-...-b671ca5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2016 License: GPL-3.0 Imports: 3 Imported by: ? modules, 0 packages

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

iso3166

A simple Go ISO-3166-2 library for dealing with country/regions/county codes.

Usage

Import with:

    import "github.com/TheBookPeople/iso3166"

Only one function exists so far:

    text, err = iso3166.Decode("GB", "", true) // will return "United Kingdom"
    text, err = iso3166.Decode("GB", "CHS", true) // will return "Cheshire"
    text, err = iso3166.Decode("", "CHS", true) // will return an error
    text, err = iso3166.Decode("", "foobar", true) // will return an error

The final bool argument specifies if additional values are to be used. E.g. GB-DVV is not a valid ISO code, but is still used in the wild. If you are translating real-world addresses, best set this to true.

Contributing

This data has not all been tested. Tests for the regions you care about are welcome.

Copyright The Book People Ltd. 2016

License

This library is distributed under the GPLv3 license found in the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(country, region string, useExtraCodes bool) (string, error)

Decode returns the name of the country based on the code. If region is empty, the country code will be returned.

func Truncate

func Truncate(code string, max int) string

Truncate - Attempts to cleanly truncates an address by removing any translation in [] brackets, and then truncating if still required.

Types

This section is empty.

Jump to

Keyboard shortcuts

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