Skip to content

Commit

Permalink
feat: add example to get data from zipcode in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
isaqueveras committed Jun 23, 2022
1 parent 59bce50 commit 76a6b6c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
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)
}
}
```

0 comments on commit 76a6b6c

Please sign in to comment.