Library to get full address of a Brazilian zip code.
Works with VipCep, Correios, and many more.
Lagoinha is a package that uses APIs to find complete addresses by a provided zip code. The lib dispatches several requests at the same time and returns with the one that finished first.
It's a Brazilian meme vídeo! (onde é que eu tô, lagoinha, CEP, endereço...)
go get -u https://github.com/IgorHalfeld/lagoinha.git
package main
import (
"fmt"
"github.com/igorhalfeld/lagoinha"
)
func main() {
// get amount of cep providers enabled
fmt.Println("Total amount of cep providers:", lagoinha.GetTotalAmountOfCepProviders())
/*
// if you want to use without handling channels
addr, err := lagoinha.GetAddressSync("15809240", &lagoinha.GetAddressOptions{
PreferenceForAPI: "Apicep",
})
*/
chResp, chErr := lagoinha.GetAddress("04568000")
select {
case address := <-chResp:
fmt.Printf("Response: %+v\n", address)
case err := <-chErr:
fmt.Printf("Error: %+v\n", err)
}
}
and you can also set a preference api
chResp, chErr := lagoinha.GetAddress("04568000", &lagoinha.GetAddressOptions{
PreferenceForAPI: "ViaCEP",
})
logo by @nelsonsecco