staddr

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

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

Go to latest
Published: Mar 9, 2016 License: MIT Imports: 2 Imported by: 0

README

go-staddr

Pacakge staddr provides tools for dealing with mailing addresses, such splitting up a street address to building number, street name, and street type.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-staddr

GoDoc

Examples

address := Address{
	CountryName: "Canada",
	Region:      "British Columbia",
	Locality:    "Vancouver",
		
	StreetAddress: "70 Murray St. West",
	UnitNumber:    "123",
	PostalCode:    "W3W 2F2",
		
	BuildingNumber: "", // <- We don't have this value.
	StreetName:     "", // <- We don't have this value.
	StreetType:     "", // <- We don't have this value.
}
	
err := address.Normalize()
if nil != err {
	//@TODO: Deal with error.
	panic(err)
}
	
// Now what we have is:
//
// address := Address{
//	CountryName: "Canada",
//	Region:      "British Columbia",
//	Locality:    "Vancouver",
//
//	StreetAddress: "", // <- Note that this is empty now.
//	UnitNumber:    "123",
//	PostalCode:    "W3W 2F2",
//
//	BuildingNumber: "70",       // <- Note that this has a value now.
//	StreetName:     "Murray",   // <- Note that this has a value now.
//	StreetType:     "St. West", // <- Note that this has a value now.
//}

Documentation

Overview

Pacakge staddr provides tools for dealing with mailing addresses, such splitting up a street address to building number, street name, and street type.

Likely you would load the fields of this, and then call the normalize method, perhaps to split up a street address into a building number, street name, and street type.

For example:

address := Address{
	CountryName: "Canada",
	Region:      "British Columbia",
	Locality:    "Vancouver",

	StreetAddress: "70 Murray St. West",
	UnitNumber:    "123",
	PostalCode:    "W3W 2F2",

	BuildingNumber: "", // <- We don't have this value.
	StreetName:     "", // <- We don't have this value.
	StreetType:     "", // <- We don't have this value.
}

err := address.Normalize()
if nil != err {
	//@TODO: Deal with error.
	panic(err)
}

// Now what we have is:
//
// address := Address{
//	CountryName: "Canada",
//	Region:      "British Columbia",
//	Locality:    "Vancouver",
//
//	StreetAddress: "", // <- Note that this is empty now.
//	UnitNumber:    "123",
//	PostalCode:    "W3W 2F2",
//
//	BuildingNumber: "70",       // <- Note that this has a value now.
//	StreetName:     "Murray",   // <- Note that this has a value now.
//	StreetType:     "St. West", // <- Note that this has a value now.
//}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	CountryName string
	Region      string
	Locality    string

	StreetAddress string
	UnitNumber    string
	PostalCode    string

	BuildingNumber string
	StreetName     string
	StreetType     string
}

Address represents a mailing address.

func (*Address) Normalize

func (address *Address) Normalize() error

Jump to

Keyboard shortcuts

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