package util import ( "errors" "fmt" "io/ioutil" "net/http" "strconv" ) func CheckError(err error) { if err != nil { panic(err) } } func Get(url string) (body string, err error) { if url == "" { err = errors.New("url is empty\n" + url) return } fmt.Println("url:", url) resp, err := http.Get(url) if err != nil || resp.StatusCode != 200 { err = errors.New("this site is not available\n" + url) return } var data []byte defer resp.Body.Close() data, err = ioutil.ReadAll(resp.Body) if err != nil { return } body = string(data) return } func GetFloat32(s string) float32 { v, err := strconv.ParseFloat(s, 32) if err != nil { v = 0 } return float32(v) }