forked from Henry-Sarabia/igdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag.go
43 lines (35 loc) · 1.02 KB
/
tag.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package igdb
import (
"strconv"
)
// Tag is a generated number that represents a specific IGDB object. Tag
// provides a quick and compact way to do complex filtering on the IGDB API.
type Tag int
// tagType represents the IGDB Object ID of a particular IGDB object type.
type tagType int
// These tagTypes correspond to their respective IGDB Object Type IDs.
//
// For the list of these IDs and other information,
// visit: https://igdb.github.io/api/references/tag-numbers/
const (
TagTheme tagType = iota
TagGenre
TagKeyword
TagGame
TagPerspective
)
// GenerateTag uses the ID of an IGDB object type and the ID of an IGDB
// object to generate a Tag addressed to that object. Negative ID values
// are considered invalid.
func GenerateTag(typeID tagType, objectID int) (Tag, error) {
if typeID < 0 || objectID < 0 {
return 0, ErrNegativeID
}
tag := int(typeID) << 28
tag |= objectID
return Tag(tag), nil
}
// String returns the provided Tag as a string.
func (t Tag) String() string {
return strconv.Itoa(int(t))
}