func (u *User) Search(query string, page int) ([]RepositorySummary, int, error) {
	page *= 20

	var summaries []RepositorySummary
	o, count, err := GetPagedResults(u, "https://store.docker.com/api/content/v1/products/search/?"+query, "summaries", page, page+20, reflect.TypeOf(summaries))
	if err != nil {
		return summaries, count, err
	}

	all := len(o.([]RepositorySummary)) == count

	// Remove possible duplicates
	done := make(map[string]int)
	for _, s := range o.([]RepositorySummary) {
		name := s.Publisher.Name + "/" + s.Name
		if _, ok := done[name]; !ok {
			summaries = append(summaries, s)
			done[name] = 1
		}
	}

	if all {
		count = len(summaries)
	}

	return summaries, count, err
}
// Note: some results might be missing because dockerhub search is inconsistent
some results might be missing because dockerhub search is inconsistent
// Note : some results might be missing because dockerhub search is inconsistent
func (u *User) Search(query string, page int) ([]RepositorySummary, int, error) {
	page *= 20
	var summaries []RepositorySummary
	o, count, err := GetPagedResults(u, "https://store.docker.com/api/content/v1/products/search/?"+query, "summaries", page, page+20, reflect.TypeOf(summaries))
	if err != nil {
		return summaries, count, err
	}
	all := len(o.([]RepositorySummary)) == count
	done := make(map[string]int)
	for _, s := range o.([]RepositorySummary) {
		name := s.Publisher.Name + "/" + s.Name
		if _, ok := done[name]; !ok {
			summaries = append(summaries, s)
			done[name] = 1
		}
	}
	if all {
		count = len(summaries)
	}
	return summaries, count, err
}
func ( u * User ) Search ( query string , page int ) ( [ ] RepositorySummary , int , error ) { page *= 20 var summaries [ ] RepositorySummary o , count , err := GetPagedResults ( u , " " + query , " " , page , page + 20 , reflect . TypeOf ( summaries ) ) if err != nil { return summaries , count , err } all := len ( o . ( [ ] RepositorySummary ) ) == count done := make ( map [ string ] int ) for _ , s := range o . ( [ ] RepositorySummary ) { name := s . Publisher . Name + " " + s . Name if _ , ok := done [ name ] ; ! ok { summaries = append ( summaries , s ) done [ name ] = 1 } } if all { count = len ( summaries ) } return summaries , count , err }
some results might be missing because dockerhub search is inconsistent
some results might be missing because dockerhub search is inconsistent
// Remove possible duplicates