ViaCEP Go client

ViaCEP Go client

Go client for ViaCEP API, used for search Brazilian Postal Codes.

Usage

Install

go get github.com/diegohordi/viacep

Creating a client

In order to use this client, you need to create your own http.Client, with your set of configurations, plus the base URL of the ViaCEP API,http://viacep.com.br/ws:

import "github.com/diegohordi/viacep"
...
httpClient := &http.Client{Timeout: time.Second * 5}
apiURL := "http://viacep.com.br/ws"
client := viacep.NewClient(apiURL, httpClient)
...
cep, err := client.Consultar(context.TODO(), "01001000")
...

Timeouts

If you need a different timeout from the base client that you created, you can create a context.WithTimeout and pass it as parameter to the functions, as they are able to deal with context signalling too.

Tests

The coverage so far is greater than 90%, covering also failure scenarios. Also, as the handlers are dealing with context timeout, there are no race conditions detected in the -race tests.

You can run the short test and the race condition test from Makefile, as below:

Short

make test_short

Race

make test_race

Integration

make test

Similar Resources

Server and client implementation of the grpc go libraries to perform unary, client streaming, server streaming and full duplex RPCs from gRPC go introduction

Description This is an implementation of a gRPC client and server that provides route guidance from gRPC Basics: Go tutorial. It demonstrates how to u

Nov 24, 2021

Devcloud-go provides a sql-driver for mysql which named devspore driver and a redis client which named devspore client,

Devcloud-go Devcloud-go provides a sql-driver for mysql which named devspore driver and a redis client which named devspore client, you can use them w

Jun 9, 2022

Client for the cloud-iso-client

cloud-iso-client Client for the cloud-iso-client. Register an API token Before using this client library, you need to register an API token under your

Dec 6, 2021

Go-http-client: An enhanced http client for Golang

Go-http-client: An enhanced http client for Golang

go-http-client An enhanced http client for Golang Documentation on go.dev 🔗 This package provides you a http client package for your http requests. Y

Jan 7, 2023

Demonstration of sharing secret data between an OAuth/OIDC client and an Identity Providers web client.

OAuth / OIDC Cubbyhole Share secret data between client applications. This is mostly a demonstration of some of the work I've been evaluating at Storj

Mar 21, 2022

Godaddy-domains-client-go - Godaddy domains api Client golang - Write automaticly from swagger codegen

Go API client for swagger Overview This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you c

Jan 9, 2022

Nutanix-client-go - Go client for the Nutanix Prism V3 API

nutanix-client-go This repository contains portions of the Nutanix API client code in nutanix/terraform-provider-nutanix. It has been extracted to red

Jan 6, 2022

Kube - A simple Kubernetes client, based on client-go

kube A simple Kubernetes client, based on client-go.

Aug 9, 2022

Aoe4-client - Client library for aoe4 leaderboards etc

AOE4 Client Overview This is a go client used to query AOE4 data from either the

Jan 18, 2022

Balabola-go-client - GO client for Yandex balabola service

Balabola GO Client GO client for Yandex balabola service Yandex warning The neur

Jan 29, 2022

Tailscale-client-go - A client implementation for the Tailscale HTTP API

tailscale-client-go A client implementation for the Tailscale HTTP API Example p

Sep 8, 2022

Client-server-golang-sqs - Client Server with SQS and golang

Client Server with SQS and golang Multi-threaded client-server demo with Go What

Feb 14, 2022

Koios-rest-go-client - Go Client library for Koios API

Koios API Client Library for Go Koios API is Elastic Cardano Query Layer! A cons

Mar 18, 2022

Comunicación de envios de archivos entres cliente-servidor, client-client.

Client - Server - Client Estes es un proyecto simple de comunicacion de envios de archivos del cliente al servidor y viceversamente, y de cliente a cl

Jul 16, 2022

go irc client for twitch.tv

go-twitch-irc This is an irc client for connecting to twitch. It handles the annoying stuff like irc tag parsing. I highly recommend reading the docum

Dec 27, 2022

Client lib for Telegram bot api

Micha Client lib for Telegram bot api. Supports Bot API v2.3.1 (of 4th Dec 2016). Simple echo bot example: package main import ( "log" "git

Nov 10, 2022

Go memcache client package

Description This is a memcache client package for the Go programming language. The following commands are implemented: get (single key) set, add, repl

Jan 8, 2022

Terminal client for SimpleNote

GoNote - Terminal client for SimpleNote GoNote is a simple utility for managing notes in your SimpleNote account. It allows basic operations like crea

Nov 22, 2022

Concurrent ssh client

go-cs Concurrent ssh client cs is a program for concurrently executing local or remote commands on multiple hosts. It is using OpenSSH for running rem

Feb 21, 2022
A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.
A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Kinesumer is a Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Jan 5, 2023
Clusterpedia-client - clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Jan 7, 2022
Client-go - Clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Dec 5, 2022
Prisma Client Go is an auto-generated and fully type-safe database client

Prisma Client Go Typesafe database access for Go Quickstart • Website • Docs • API reference • Blog • Slack • Twitter Prisma Client Go is an auto-gene

Jan 9, 2023
The Dual-Stack Dynamic DNS client, the world's first dynamic DNS client built for IPv6.

dsddns DsDDNS is the Dual-Stack Dynamic DNS client. A dynamic DNS client keeps your DNS records in sync with the IP addresses associated with your hom

Sep 27, 2022
The Fabric Smart Client is a new Fabric Client that lets you focus on the business processes and simplifies the development of Fabric-based distributed application.

Fabric Smart Client The Fabric Smart Client (FSC, for short) is a new Fabric client-side component whose objective is twofold. FSC aims to simplify th

Dec 14, 2022
this is a funny client for jsonrpc-client. it can support timeout,breaker ...

this is a funny client for jsonrpc-client. it can support timeout,breaker ...

Sep 17, 2022
Awesome WebSocket CLient - an interactive command line client for testing websocket servers
Awesome WebSocket CLient - an interactive command line client for testing websocket servers

Awesome WebSocket CLient - an interactive command line client for testing websocket servers

Dec 30, 2022
Chief Client Go is a cross platform Krunker client written in Go Lang

Chief Client Go Chief Client Go is a client for Mac and Linux written in GoLang Features Ad Blocker Option to use proxy Installation To install this c

Nov 6, 2021
Go Substrate RPC Client (GSRPC)Go Substrate RPC Client (GSRPC)

Go Substrate RPC Client (GSRPC) Substrate RPC client in Go. It provides APIs and types around Polkadot and any Substrate-based chain RPC calls. This c

Nov 11, 2021