-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add example to get data from zipcode in readme
- Loading branch information
1 parent
59bce50
commit 76a6b6c
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,36 @@ | ||
# brasilapi-go | ||
Cliente em Golang para se comunicar com BrasilApi | ||
|
||
## Cep (zipcode) | ||
Para buscar dados referente a um CEP basta utilizar a função `GetZipCode(zipcode)` | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/isaqueveras/brasilapi-go" | ||
) | ||
|
||
func main() { | ||
zp, err := brasilapi.GetZipCode("63900-193") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
fmt.Println(*zp.Cep) | ||
fmt.Println(*zp.City) | ||
fmt.Println(*zp.Service) | ||
fmt.Println(*zp.State) | ||
|
||
if zp.Location != nil { | ||
fmt.Println(*zp.Location.Type) | ||
} | ||
|
||
if zp.Location != nil && zp.Location.Coordenates != nil { | ||
fmt.Println(*zp.Location.Coordenates.Longitude) | ||
fmt.Println(*zp.Location.Coordenates.Latitude) | ||
} | ||
} | ||
``` |