stdxgit.sr.ht/~pingoo/stdx/countries Index | Files

package countries

import "git.sr.ht/~pingoo/stdx/countries"

Index

Constants

const (
	Unknown     = "Unknown"
	CodeUnknown = "XX"
)

Variables

var Bytes []byte
var (
	ErrCountryNotFound = errors.New("Country not found")
)

Functions

func GetMap

func GetMap() map[string]Country

func Init

func Init() (err error)

func Name

func Name(countryCode string) (countryName string, err error)

Types

type Country

type Country struct {
	Name string `json:"name"`
	Code string `json:"code"`
}

func GetList

func GetList() []Country

type CountryInt32

type CountryInt32 string

CountryInt32 is a tpye that store a 2-letters country code as an int32. The goal is to have more efficient database operations than using the a basic TEXT

func (*CountryInt32) Scan

func (country *CountryInt32) Scan(src interface{}) (err error)

Scan implements sql.Scanner so CountryInt32 can be read from databases transparently.

func (CountryInt32) Value

func (country CountryInt32) Value() (driver.Value, error)

Value implements sql.Valuer so that CountryInt32 can be written to databases

Source Files

countries.go countryint32.go

Version
v0.0.0-20240218134121-094174641f6e (latest)
Published
Feb 18, 2024
Platform
linux/amd64
Imports
5 packages
Last checked
4 months ago

Tools for package owners.