Explode one-line address strings using Golang.
This package uses the Google Maps API to geocode the address. Don't forget to set your GOOGLE_MAPS_API_KEY
environment variable.
go get -u github.com/mattevans/abode
Explode your one-line address...
yourAddress := "193 Rogers Ave, Brooklyn, New York"
// Explode our one-line address into components.
address, err := abode.Explode(yourAddress)
if err != nil {
return err
}
Which will give you...
abode.Address{
AddressLine1: "193 Rogers Avenue",
AddressLine2: "Brooklyn"
AddressCity: nil,
AddressState: "New York"
AddressCountry: "United States"
AddressZip: "11216"
AddressLat: 40.6706073,
AddressLng: -73.9530182,
FormattedAddress: "193 Rogers Ave, Brooklyn, NY 11216, USA",
}
Each abode.Address{}
component can be tailored to meet your needs. Simply adjust the mapping of the Google Maps Address Components here.
Ensure your end results are used in conjunction with a Google Map to avoid violating the Google Maps API Terms of Service.