3 Commits

Author SHA1 Message Date
aaf697a005 refactor: Improve endpoint robustness and client clarity
Refactored client request parameter naming and enhanced endpoint methods for better validation and idiomatic behavior.

- Renamed `URL` parameter to `requestURL` in `Client.Request` for improved clarity and to avoid potential naming conflicts.
- Added validation to `BaseEndpoint.GetByID` to prevent queries with an ID of 0, returning an error.
- Modified `BaseEndpoint.GetByIDs` to return an empty slice (`[]*T{}`) instead of an error when no IDs are provided, aligning with common Go idioms for empty result sets.
- Enhanced `BaseEndpoint.Count` method to return an error if the API reports a count of 0, ensuring that a successful count operation always yields a positive result.
2025-11-03 18:25:53 +11:00
7ef9cb37e6 refactor(module): Migrate module path to nite07.com domain 2025-10-29 20:23:42 +11:00
87afdc63b8 u 2025-10-28 22:36:26 +11:00
75 changed files with 89 additions and 361 deletions

View File

@@ -14,7 +14,7 @@ A Go client library for the IGDB (Internet Game Database) API v4. This library p
## Installation ## Installation
```bash ```bash
go get github.com/bestnite/go-igdb go get git.nite07.com/nite/go-igdb
``` ```
## Quick Start ## Quick Start
@@ -25,7 +25,7 @@ package main
import ( import (
"log" "log"
"github.com/bestnite/go-igdb" "git.nite07.com/nite/go-igdb"
) )
func Test1(c *igdb.Client) { func Test1(c *igdb.Client) {

View File

@@ -5,8 +5,8 @@ import (
"fmt" "fmt"
"strings" "strings"
"git.nite07.com/nite/go-igdb/endpoint"
"github.com/bestnite/go-flaresolverr" "github.com/bestnite/go-flaresolverr"
"github.com/bestnite/go-igdb/endpoint"
"golang.org/x/time/rate" "golang.org/x/time/rate"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
@@ -113,7 +113,7 @@ func NewWithFlaresolverr(clientID, clientSecret string, f *flaresolverr.Flaresol
return c return c
} }
func (g *Client) Request(ctx context.Context, method string, URL string, dataBody any) (*resty.Response, error) { func (g *Client) Request(ctx context.Context, method string, requestURL string, dataBody any) (*resty.Response, error) {
err := g.limiter.Wait(ctx) err := g.limiter.Wait(ctx)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get rate limiter token: %w", err) return nil, fmt.Errorf("failed to get rate limiter token: %w", err)
@@ -129,14 +129,14 @@ func (g *Client) Request(ctx context.Context, method string, URL string, dataBod
"Authorization": "Bearer " + t, "Authorization": "Bearer " + t,
"User-Agent": "", "User-Agent": "",
"Content-Type": "text/plain", "Content-Type": "text/plain",
}).Execute(strings.ToUpper(method), URL) }).Execute(strings.ToUpper(method), requestURL)
if resp.StatusCode() != 200 { if resp.StatusCode() != 200 {
return nil, fmt.Errorf("failed to request, expected 200 but got: %v", resp.StatusCode()) return nil, fmt.Errorf("failed to request, expected 200 but got: %v", resp.StatusCode())
} }
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %s: %w", URL, err) return nil, fmt.Errorf("failed to request: %s: %w", requestURL, err)
} }
return resp, nil return resp, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *AgeRatingCategories) Query(ctx context.Context, query string) ([]*pb.Ag
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Ageratingcategories) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Ageratingcategories, nil return data.Ageratingcategories, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *AgeRatingContentDescriptions) Query(ctx context.Context, query string)
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Ageratingcontentdescriptions) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Ageratingcontentdescriptions, nil return data.Ageratingcontentdescriptions, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *AgeRatingContentDescriptionsV2) Query(ctx context.Context, query string
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Ageratingcontentdescriptionsv2) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Ageratingcontentdescriptionsv2, nil return data.Ageratingcontentdescriptionsv2, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *AgeRatingOrganizations) Query(ctx context.Context, query string) ([]*pb
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Ageratingorganizations) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Ageratingorganizations, nil return data.Ageratingorganizations, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *AgeRatings) Query(ctx context.Context, query string) ([]*pb.AgeRating,
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Ageratings) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Ageratings, nil return data.Ageratings, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *AlternativeNames) Query(ctx context.Context, query string) ([]*pb.Alter
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Alternativenames) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Alternativenames, nil return data.Alternativenames, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Artworks) Query(ctx context.Context, query string) ([]*pb.Artwork, erro
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Artworks) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Artworks, nil return data.Artworks, nil
} }

View File

@@ -2,11 +2,12 @@ package endpoint
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
@@ -32,6 +33,9 @@ func (b *BaseEndpoint[T]) Query(ctx context.Context, query string) ([]*T, error)
} }
func (b *BaseEndpoint[T]) GetByID(ctx context.Context, id uint64) (*T, error) { func (b *BaseEndpoint[T]) GetByID(ctx context.Context, id uint64) (*T, error) {
if id == 0 {
return nil, errors.New("id cant be 0")
}
res, err := b.Query(ctx, fmt.Sprintf("where id = %d; fields *;", id)) res, err := b.Query(ctx, fmt.Sprintf("where id = %d; fields *;", id))
if err != nil { if err != nil {
return nil, err return nil, err
@@ -44,7 +48,7 @@ func (b *BaseEndpoint[T]) GetByID(ctx context.Context, id uint64) (*T, error) {
func (b *BaseEndpoint[T]) GetByIDs(ctx context.Context, ids []uint64) ([]*T, error) { func (b *BaseEndpoint[T]) GetByIDs(ctx context.Context, ids []uint64) ([]*T, error) {
if len(ids) == 0 { if len(ids) == 0 {
return nil, fmt.Errorf("ids cant be empty") return []*T{}, nil
} }
batches := make([][]uint64, 0) batches := make([][]uint64, 0)
for i := 0; i < len(ids); i += 500 { for i := 0; i < len(ids); i += 500 {
@@ -80,7 +84,11 @@ func (b *BaseEndpoint[T]) Count(ctx context.Context) (uint64, error) {
return 0, fmt.Errorf("failed to unmarshal: %w", err) return 0, fmt.Errorf("failed to unmarshal: %w", err)
} }
return uint64(res.Count), nil if res.Count > 0 {
return uint64(res.Count), nil
} else {
return 0, fmt.Errorf("failed to count, count should larger than 0, but got %v", res.Count)
}
} }
func (b *BaseEndpoint[T]) Paginated(ctx context.Context, offset, limit uint64) ([]*T, error) { func (b *BaseEndpoint[T]) Paginated(ctx context.Context, offset, limit uint64) ([]*T, error) {

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CharacterGenders) Query(ctx context.Context, query string) ([]*pb.Chara
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Charactergenders) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Charactergenders, nil return data.Charactergenders, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CharacterMugShots) Query(ctx context.Context, query string) ([]*pb.Char
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Charactermugshots) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Charactermugshots, nil return data.Charactermugshots, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CharacterSpecies) Query(ctx context.Context, query string) ([]*pb.Chara
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Characterspecies) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Characterspecies, nil return data.Characterspecies, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Characters) Query(ctx context.Context, query string) ([]*pb.Character,
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Characters) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Characters, nil return data.Characters, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CollectionMembershipTypes) Query(ctx context.Context, query string) ([]
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Collectionmembershiptypes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Collectionmembershiptypes, nil return data.Collectionmembershiptypes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CollectionMemberships) Query(ctx context.Context, query string) ([]*pb.
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Collectionmemberships) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Collectionmemberships, nil return data.Collectionmemberships, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CollectionRelationTypes) Query(ctx context.Context, query string) ([]*p
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Collectionrelationtypes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Collectionrelationtypes, nil return data.Collectionrelationtypes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CollectionRelations) Query(ctx context.Context, query string) ([]*pb.Co
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Collectionrelations) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Collectionrelations, nil return data.Collectionrelations, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CollectionTypes) Query(ctx context.Context, query string) ([]*pb.Collec
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Collectiontypes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Collectiontypes, nil return data.Collectiontypes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Collections) Query(ctx context.Context, query string) ([]*pb.Collection
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Collections) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Collections, nil return data.Collections, nil
} }

View File

@@ -2,10 +2,9 @@ package endpoint
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -36,9 +35,5 @@ func (a *Companies) Query(ctx context.Context, query string) ([]*pb.Company, err
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Companies) == 0 {
return nil, errors.New("no results")
}
return data.Companies, nil return data.Companies, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CompanyLogos) Query(ctx context.Context, query string) ([]*pb.CompanyLo
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Companylogos) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Companylogos, nil return data.Companylogos, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CompanyStatuses) Query(ctx context.Context, query string) ([]*pb.Compan
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Companystatuses) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Companystatuses, nil return data.Companystatuses, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *CompanyWebsites) Query(ctx context.Context, query string) ([]*pb.Compan
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Companywebsites) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Companywebsites, nil return data.Companywebsites, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Covers) Query(ctx context.Context, query string) ([]*pb.Cover, error) {
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Covers) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Covers, nil return data.Covers, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *DateFormats) Query(ctx context.Context, query string) ([]*pb.DateFormat
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Dateformats) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Dateformats, nil return data.Dateformats, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *EventLogos) Query(ctx context.Context, query string) ([]*pb.EventLogo,
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Eventlogos) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Eventlogos, nil return data.Eventlogos, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *EventNetworks) Query(ctx context.Context, query string) ([]*pb.EventNet
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Eventnetworks) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Eventnetworks, nil return data.Eventnetworks, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Events) Query(ctx context.Context, query string) ([]*pb.Event, error) {
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Events) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Events, nil return data.Events, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *ExternalGameSources) Query(ctx context.Context, query string) ([]*pb.Ex
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Externalgamesources) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Externalgamesources, nil return data.Externalgamesources, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *ExternalGames) Query(ctx context.Context, query string) ([]*pb.External
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Externalgames) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Externalgames, nil return data.Externalgames, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Franchises) Query(ctx context.Context, query string) ([]*pb.Franchise,
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Franchises) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Franchises, nil return data.Franchises, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameEngineLogos) Query(ctx context.Context, query string) ([]*pb.GameEn
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gameenginelogos) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gameenginelogos, nil return data.Gameenginelogos, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameEngines) Query(ctx context.Context, query string) ([]*pb.GameEngine
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gameengines) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gameengines, nil return data.Gameengines, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameLocalizations) Query(ctx context.Context, query string) ([]*pb.Game
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gamelocalizations) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gamelocalizations, nil return data.Gamelocalizations, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameModes) Query(ctx context.Context, query string) ([]*pb.GameMode, er
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gamemodes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gamemodes, nil return data.Gamemodes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameReleaseFormats) Query(ctx context.Context, query string) ([]*pb.Gam
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gamereleaseformats) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gamereleaseformats, nil return data.Gamereleaseformats, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameStatuses) Query(ctx context.Context, query string) ([]*pb.GameStatu
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gamestatuses) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gamestatuses, nil return data.Gamestatuses, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameTimeToBeats) Query(ctx context.Context, query string) ([]*pb.GameTi
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gametimetobeats) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gametimetobeats, nil return data.Gametimetobeats, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameTypes) Query(ctx context.Context, query string) ([]*pb.GameType, er
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gametypes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gametypes, nil return data.Gametypes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameVersionFeatureValues) Query(ctx context.Context, query string) ([]*
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gameversionfeaturevalues) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gameversionfeaturevalues, nil return data.Gameversionfeaturevalues, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameVersionFeatures) Query(ctx context.Context, query string) ([]*pb.Ga
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gameversionfeatures) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gameversionfeatures, nil return data.Gameversionfeatures, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameVersions) Query(ctx context.Context, query string) ([]*pb.GameVersi
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gameversions) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gameversions, nil return data.Gameversions, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *GameVideos) Query(ctx context.Context, query string) ([]*pb.GameVideo,
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Gamevideos) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Gamevideos, nil return data.Gamevideos, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Games) Query(ctx context.Context, query string) ([]*pb.Game, error) {
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Games) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Games, nil return data.Games, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Genres) Query(ctx context.Context, query string) ([]*pb.Genre, error) {
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Genres) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Genres, nil return data.Genres, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *InvolvedCompanies) Query(ctx context.Context, query string) ([]*pb.Invo
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Involvedcompanies) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Involvedcompanies, nil return data.Involvedcompanies, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Keywords) Query(ctx context.Context, query string) ([]*pb.Keyword, erro
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Keywords) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Keywords, nil return data.Keywords, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *LanguageSupportTypes) Query(ctx context.Context, query string) ([]*pb.L
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Languagesupporttypes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Languagesupporttypes, nil return data.Languagesupporttypes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *LanguageSupports) Query(ctx context.Context, query string) ([]*pb.Langu
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Languagesupports) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Languagesupports, nil return data.Languagesupports, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Languages) Query(ctx context.Context, query string) ([]*pb.Language, er
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Languages) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Languages, nil return data.Languages, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *MultiplayerModes) Query(ctx context.Context, query string) ([]*pb.Multi
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Multiplayermodes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Multiplayermodes, nil return data.Multiplayermodes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *NetworkTypes) Query(ctx context.Context, query string) ([]*pb.NetworkTy
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Networktypes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Networktypes, nil return data.Networktypes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PlatformFamilies) Query(ctx context.Context, query string) ([]*pb.Platf
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Platformfamilies) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Platformfamilies, nil return data.Platformfamilies, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PlatformLogos) Query(ctx context.Context, query string) ([]*pb.Platform
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Platformlogos) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Platformlogos, nil return data.Platformlogos, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PlatformTypes) Query(ctx context.Context, query string) ([]*pb.Platform
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Platformtypes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Platformtypes, nil return data.Platformtypes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PlatformVersionCompanies) Query(ctx context.Context, query string) ([]*
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Platformversioncompanies) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Platformversioncompanies, nil return data.Platformversioncompanies, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PlatformVersionReleaseDates) Query(ctx context.Context, query string) (
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Platformversionreleasedates) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Platformversionreleasedates, nil return data.Platformversionreleasedates, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PlatformVersions) Query(ctx context.Context, query string) ([]*pb.Platf
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Platformversions) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Platformversions, nil return data.Platformversions, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PlatformWebsites) Query(ctx context.Context, query string) ([]*pb.Platf
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Platformwebsites) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Platformwebsites, nil return data.Platformwebsites, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,8 +35,5 @@ func (a *Platforms) Query(ctx context.Context, query string) ([]*pb.Platform, er
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Platforms) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Platforms, nil return data.Platforms, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PlayerPerspectives) Query(ctx context.Context, query string) ([]*pb.Pla
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Playerperspectives) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Playerperspectives, nil return data.Playerperspectives, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PopularityPrimitives) Query(ctx context.Context, query string) ([]*pb.P
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Popularityprimitives) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Popularityprimitives, nil return data.Popularityprimitives, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *PopularityTypes) Query(ctx context.Context, query string) ([]*pb.Popula
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Popularitytypes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Popularitytypes, nil return data.Popularitytypes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Regions) Query(ctx context.Context, query string) ([]*pb.Region, error)
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Regions) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Regions, nil return data.Regions, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *ReleaseDateRegions) Query(ctx context.Context, query string) ([]*pb.Rel
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Releasedateregions) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Releasedateregions, nil return data.Releasedateregions, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *ReleaseDateStatuses) Query(ctx context.Context, query string) ([]*pb.Re
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Releasedatestatuses) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Releasedatestatuses, nil return data.Releasedatestatuses, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *ReleaseDates) Query(ctx context.Context, query string) ([]*pb.ReleaseDa
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Releasedates) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Releasedates, nil return data.Releasedates, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Screenshots) Query(ctx context.Context, query string) ([]*pb.Screenshot
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Screenshots) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Screenshots, nil return data.Screenshots, nil
} }

View File

@@ -10,7 +10,7 @@ import (
"strings" "strings"
"time" "time"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
"github.com/bestnite/go-flaresolverr" "github.com/bestnite/go-flaresolverr"
@@ -46,10 +46,6 @@ func (a *Search) Search(ctx context.Context, query string) ([]*pb.Search, error)
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Searches) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Searches, nil return data.Searches, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Themes) Query(ctx context.Context, query string) ([]*pb.Theme, error) {
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Themes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Themes, nil return data.Themes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *WebsiteTypes) Query(ctx context.Context, query string) ([]*pb.WebsiteTy
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Websitetypes) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Websitetypes, nil return data.Websitetypes, nil
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "git.nite07.com/nite/go-igdb/proto"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -35,9 +35,5 @@ func (a *Websites) Query(ctx context.Context, query string) ([]*pb.Website, erro
return nil, fmt.Errorf("failed to unmarshal: %w", err) return nil, fmt.Errorf("failed to unmarshal: %w", err)
} }
if len(data.Websites) == 0 {
return nil, fmt.Errorf("no results: %s", query)
}
return data.Websites, nil return data.Websites, nil
} }

2
go.mod
View File

@@ -1,4 +1,4 @@
module github.com/bestnite/go-igdb module git.nite07.com/nite/go-igdb
go 1.24.1 go 1.24.1

View File

@@ -1,7 +1,7 @@
package igdb package igdb
import ( import (
"github.com/bestnite/go-igdb/endpoint" "git.nite07.com/nite/go-igdb/endpoint"
) )
func registerAllEndpoints(c *Client) { func registerAllEndpoints(c *Client) {