Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
golint
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Jan 18, 2018
1 parent 934d608 commit bbb3bf6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions coinmarketcap.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Coin Market Cap API fo golang
// Package coinmarketcap Coin Market Cap API fo golang
package coinmarketcap

import (
Expand All @@ -13,14 +13,14 @@ import (
)

var (
baseUrl = "https://api.coinmarketcap.com/v1"
graphUrl = "https://graphs2.coinmarketcap.com/currencies"
baseURL = "https://api.coinmarketcap.com/v1"
graphURL = "https://graphs2.coinmarketcap.com/currencies"
url string
)

// GetMarketData get information about the global market data of the cryptocurrencies
func GetMarketData() (GlobalMarketData, error) {
url = fmt.Sprintf(baseUrl + "/global/")
url = fmt.Sprintf(baseURL + "/global/")

resp, err := makeReq(url)

Expand All @@ -35,7 +35,7 @@ func GetMarketData() (GlobalMarketData, error) {

// GetCoinData get information about a crypto currency
func GetCoinData(coin string) (Coin, error) {
url = fmt.Sprintf("%s/ticker/%s", baseUrl, coin)
url = fmt.Sprintf("%s/ticker/%s", baseURL, coin)
resp, err := makeReq(url)
if err != nil {
return Coin{}, err
Expand All @@ -55,7 +55,7 @@ func GetAllCoinData(limit int) (map[string]Coin, error) {
if limit >= 0 {
l = fmt.Sprintf("?limit=%v", limit)
}
url = fmt.Sprintf("%s/ticker/%s", baseUrl, l)
url = fmt.Sprintf("%s/ticker/%s", baseURL, l)

resp, err := makeReq(url)

Expand All @@ -75,7 +75,7 @@ func GetAllCoinData(limit int) (map[string]Coin, error) {

// GetCoinGraphData get graph data points for a crypto currency
func GetCoinGraphData(coin string, start int64, end int64) (CoinGraph, error) {
url = fmt.Sprintf("%s/%s/%d/%d", graphUrl, coin, start*1000, end*1000)
url = fmt.Sprintf("%s/%s/%d/%d", graphURL, coin, start*1000, end*1000)
resp, err := makeReq(url)
if err != nil {
return CoinGraph{}, err
Expand Down Expand Up @@ -150,13 +150,13 @@ func makeReq(url string) ([]byte, error) {
}

// helper Function for CoinMarkets
func toInt(raw_int string) int {
parsed, _ := strconv.Atoi(strings.Replace(strings.Replace(raw_int, "$", "", -1), ",", "", -1))
func toInt(rawInt string) int {
parsed, _ := strconv.Atoi(strings.Replace(strings.Replace(rawInt, "$", "", -1), ",", "", -1))
return parsed
}

// helper Function for CoinMarkets
func toFloat(raw_float string) float64 {
parsed, _ := strconv.ParseFloat(strings.Replace(strings.Replace(strings.Replace(raw_float, "$", "", -1), ",", "", -1), "%", "", -1), 64)
func toFloat(rawFloat string) float64 {
parsed, _ := strconv.ParseFloat(strings.Replace(strings.Replace(strings.Replace(rawFloat, "$", "", -1), ",", "", -1), "%", "", -1), 64)
return parsed
}
6 changes: 3 additions & 3 deletions types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package coinmarketcap

//Coin struct
// Coin struct
type Coin struct {
ID string `json:"id"`
Name string `json:"name"`
Expand All @@ -18,7 +18,7 @@ type Coin struct {
LastUpdated string `json:"last_updated"`
}

//GlobalMarketData struct
// GlobalMarketData struct
type GlobalMarketData struct {
TotalMarketCapUsd float64 `json:"total_market_cap_usd"`
Total24hVolumeUsd float64 `json:"total_24h_volume_usd"`
Expand All @@ -36,7 +36,7 @@ type CoinGraph struct {
VolumeUsd [][]float64 `json:"volume_usd"`
}

//CoinMarkets struct
// Market struct
type Market struct {
Rank int
Exchange string
Expand Down

0 comments on commit bbb3bf6

Please sign in to comment.