Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itsksaurabh/go-corona
go-corona is a Golang client library for accessing global coronavirus (COVID-19, SARS-CoV-2) outbreak data.
https://github.com/itsksaurabh/go-corona
corona coronavirus coronavirus-analysis coronavirus-globaloutbreak coronavirus-info coronavirus-real-time coronavirus-tracker coronavirus-tracking covid covid-19 covid-data covid19-data go go-library golang golang-library ncov ncov-2019 ncov-tracker
Last synced: about 2 months ago
JSON representation
go-corona is a Golang client library for accessing global coronavirus (COVID-19, SARS-CoV-2) outbreak data.
- Host: GitHub
- URL: https://github.com/itsksaurabh/go-corona
- Owner: itsksaurabh
- License: mit
- Created: 2020-03-20T07:10:09.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-25T18:35:45.000Z (over 4 years ago)
- Last Synced: 2024-06-18T23:14:21.619Z (7 months ago)
- Topics: corona, coronavirus, coronavirus-analysis, coronavirus-globaloutbreak, coronavirus-info, coronavirus-real-time, coronavirus-tracker, coronavirus-tracking, covid, covid-19, covid-data, covid19-data, go, go-library, golang, golang-library, ncov, ncov-2019, ncov-tracker
- Language: Go
- Homepage:
- Size: 171 KB
- Stars: 57
- Watchers: 4
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# go-corona
[![itsksaurabh](https://circleci.com/gh/itsksaurabh/go-corona.svg?style=shield)](https://circleci.com/gh/itsksaurabh/workflows/go-corona/tree/master)
[![Go Report Card](https://goreportcard.com/badge/github.com/itsksaurabh/go-corona)](https://goreportcard.com/report/github.com/itsksaurabh/go-corona)
[![GoDoc](https://godoc.org/github.com/itsksaurabh/go-corona?status.svg)](https://godoc.org/github.com/itsksaurabh/go-corona)
[![Built with Mage](https://magefile.org/badge.svg)](https://magefile.org)
[![MIT License](https://img.shields.io/github/license/itsksaurabh/go-corona?style=social)](https://github.com/itsksaurabh/go-corona/blob/master/LICENSE)
#### go-corona is a [Golang](http://golang.org/) client library for accessing global coronavirus (COVID-19, SARS-CoV-2) outbreak data.
## API Documentation
It consumes data from [Coronavirus Tracker API](https://github.com/ExpDev07/coronavirus-tracker-api). You can read the API server documentation [here](https://github.com/ExpDev07/coronavirus-tracker-api).#### Available data sources:
* **JHU** - https://github.com/CSSEGISandData/COVID-19 - Data repository operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE). More data sources to be added later.
## Installation
Make sure you have set the environment variable $GOPATH
```bash
export GOPATH="path/to/your/go/folder"
```Obtain the latest version of the go-corona library with:
```bash
go get github.com/itsksaurabh/go-corona
```Then, add the following to your Golang project:
```go
import (
"github.com/itsksaurabh/go-corona"
)
```## Usage
Package provides a client for accessing different endpoints of the API.
Create a new instance of Client, then use the various methods on the client to access different parts of the API.For demonstration:
```go
package mainimport (
"context"
"fmt"
"log"
"github.com/itsksaurabh/go-corona"
)func main() {
// client for accessing different endpoints of the API
client := gocorona.Client{}
ctx := context.Background()
// GetLatestData returns total amonut confirmed cases, deaths, and recoveries.
data, err := client.GetLatestData(ctx)
if err != nil {
log.Fatal("request failed:", err)
}
fmt.Println(data)
}```
Notes:
* Using the [https://godoc.org/context](https://godoc.org/context) package for passing context.
* Look at tests(*_test.go) files for more sample usage.## Error Handling
All errors generated at runtime will be returned to the calling client method. Any API request for which the API returns an error encoded in a JSON response will be parsed and returned by the client method as a Golang error struct. Lastly, it is important to note that for HTTP requests, if the response code returned is not '200 OK', an error will be returned to the client method detailing the response code that was received.
## Testing
In order to run the tests for this library, you will first need to install [Mage](https://magefile.org/) - A Make/rake-like dev tool using Go. You can install the dependency with the following command:
**Using GOPATH**
```bash
go get -u -d github.com/magefile/mage
cd $GOPATH/src/github.com/magefile/mage
go run bootstrap.go
```**Using Go Modules**
```bash
git clone https://github.com/magefile/mage
cd mage
go run bootstrap.go
```
The mage binary will be created in your `$GOPATH/bin` directory.
You may also install a binary release from Mage's [releases](https://github.com/magefile/mage/releases) page.Then run all tests by executing the following in your command line:
$ mage -v Test**Updating Test Data**
You can update the test data inside `./testdata/` directory by enabling the `-update` flag while testing. By default the flag is set to `false`.
Or
simply Run the following command to update all test data :
```sh
$ mage generate
```# Contributing
I welcome pull requests, bug fixes and issue reports. Before proposing a change, please discuss your change by raising an issue.# Maintainer
[Kumar Saurabh](https://in.linkedin.com/in/itsksaurabh)
## License
[MIT](LICENSE) © Kumar Saurabh
## Logo Attributions
The project Logo is made using the Go gopher designed by [Renee French](http://reneefrench.blogspot.com/) and the Gopher sticker made by [Takuya Ueda](https://twitter.com/tenntenn). The Go Logo is copyrighted by the Go authors. All of the logo materials are licensed under the Creative Commons 3.0 Attributions license.