// Searches appStore by a term and returns results in channel
Searches appStore by a term and returns results in channel
// Searches appStore by a term and returns results in channel
func searchApple(criteria string) []AppleSearchAppInfo {
	url := APPLE_SEARCH_API + "term=" + url.QueryEscape(criteria) + "&media=software" + "&limit=8"
	response, err := http.Get(url)
	if err != nil {
		log.Println("Error: The HTTP request failed with error: " + err.Error())
		return nil
	}
	responseData, err := ioutil.ReadAll(response.Body)
	if err != nil {
		log.Println("Error: Reading http response failed with error: " + err.Error())
		return nil
	}
	appleSearchAPiRes := AppleSearchResponse{}
	err = json.Unmarshal(responseData, &appleSearchAPiRes)
	if err != nil {
		log.Println("Error: Parsing http response as json failed with error: " + err.Error())
		return nil
	}
	var res = make([]AppleSearchAppInfo, appleSearchAPiRes.ResultCount)
	for i := 0; i < appleSearchAPiRes.ResultCount && i < 8; i++ {
		res[i] = appleSearchAPiRes.Results[i]
	}
	return res
}
func searchApple ( criteria string ) [ ] AppleSearchAppInfo { url := APPLE_SEARCH_API + " " + url . QueryEscape ( criteria ) + " " + " " response , err := http . Get ( url ) if err != nil { log . Println ( " " + err . Error ( ) ) return nil } responseData , err := ioutil . ReadAll ( response . Body ) if err != nil { log . Println ( " " + err . Error ( ) ) return nil } appleSearchAPiRes := AppleSearchResponse { } err = json . Unmarshal ( responseData , & appleSearchAPiRes ) if err != nil { log . Println ( " " + err . Error ( ) ) return nil } var res = make ( [ ] AppleSearchAppInfo , appleSearchAPiRes . ResultCount ) for i := 0 ; i < appleSearchAPiRes . ResultCount && i < 8 ; i ++ { res [ i ] = appleSearchAPiRes . Results [ i ] } return res }
Searches appStore by a term and returns results in channel
Searches appStore by a term and returns results in channel