18 lines
317 B
Go
18 lines
317 B
Go
package catalogue
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func readJson(url string, target interface{}) error {
|
|
httpClient := &http.Client{Timeout: 5 * time.Second}
|
|
res, err := httpClient.Get(url)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer res.Body.Close()
|
|
return json.NewDecoder(res.Body).Decode(target)
|
|
}
|