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

Commit

Permalink
Removed global variable url
Browse files Browse the repository at this point in the history
  • Loading branch information
darccio committed Feb 18, 2018
1 parent ee912e4 commit 6fa7201
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions coinmarketcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ import (
var (
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 @@ -36,7 +35,7 @@ func GetMarketData() (GlobalMarketData, error) {
// GetCoinData get information about a crypto currency
func GetCoinData(coin string) (Coin, error) {
coin = strings.ToLower(coin)
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 @@ -56,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 @@ -76,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

0 comments on commit 6fa7201

Please sign in to comment.