Help us shape the future of Go! Take the 2026 Go Developer Survey

address

package module
v0.0.0-...-5f4116a Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 4 Imported by: 0

README

golang-address

Normalizer / Parser for physical US addresses.

Motivation

Is your inherited legacy system getting you down?

Did you finally decide to throw up a quick Go API to wrap around some awful mess of Oracle stored procedures and un-touchable PHP scripts, only to find that "StreetName", "StreetType", "StreetDirection", etc. are individual fields in an overpriced database which doesn't have a proper GIS plugin?

Worried that you'll have to deal with splitting and normalizing addresses for all of your forms without creating separate fields for each item?

Me too.

So here you go.

Documentation

Overview

golang-address parses and validates US addresses according to USPS standards.

Index

Constants

This section is empty.

Variables

View Source
var CardinalDirectionAbbreviations map[string]string = map[string]string{
	"north": "n",
	"n":     "n",

	"northwest": "nw",
	"nw":        "nw",

	"northeast": "ne",
	"ne":        "ne",

	"south": "s",
	"s":     "s",

	"southwest": "sw",
	"sw":        "sw",

	"southeast": "se",
	"se":        "se",

	"east": "e",
	"e":    "e",

	"west": "w",
	"w":    "w",
}
View Source
var NumberRequired []string = []string{
	"po box",
	"rr",
	"county road",
	"cr",
}
View Source
var Pairs map[string]string = map[string]string{
	"po":     "box",
	"county": "road",
}
View Source
var RuralBoxes map[string]string = map[string]string{
	"cr":          "county road",
	"county road": "county road",

	"rr": "rr",

	"po box": "po box",
}
View Source
var StreetTypeAbbreviations map[string]string = map[string]string{}/* 507 elements not displayed */

http://pe.usps.gov/text/pub28/28apc_002.htm Include a key that matches the value (ex; "avn": "avn") to make validating valid strings easy. If these change, pull requests are welcome!

View Source
var SuiteTypeAbbreviations map[string]string = map[string]string{
	"apartment": "apt",
	"#":         "apt",
	"apt":       "apt",

	"building": "bldg",
	"bldg":     "bldg",

	"floor": "fl",
	"fl":    "fl",

	"suite": "ste",
	"ste":   "ste",

	"unit": "unit",

	"room": "rm",
	"rm":   "rm",

	"department": "dept",
	"dept":       "dept",

	"box": "box",
	"lot": "lot",
}

Functions

This section is empty.

Types

type Address

type Address struct {
	House           int
	StreetDirection string
	StreetName      string
	StreetType      string
	SuiteType       string
	SuiteNumber     string
}

func Normalize

func Normalize(s string) (a Address, err error)

Jump to

Keyboard shortcuts

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