Repository: rclone/rclone
File: backend/box/api/types.go (Go)

Code before:
	PrivateKey  string `json:"privateKey"`
	Passphrase  string `json:"passphrase"`
}

// User is returned from /users/me
type User struct {
	Type          string    `json:"type"`
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	Login         string    `json:"login"`
	CreatedAt     time.Time `json:"created_at"`
	ModifiedAt    time.Time `json:"modified_at"`
	Language      string    `json:"language"`
	Timezone      string    `json:"timezone"`
	SpaceAmount   int64     `json:"space_amount"`
	SpaceUsed     int64     `json:"space_used"`
	MaxUploadSize int64     `json:"max_upload_size"`
	Status        string    `json:"status"`
	JobTitle      string    `json:"job_title"`
	Phone         string    `json:"phone"`
	Address       string    `json:"address"`
	AvatarURL     string    `json:"avatar_url"`
}

// Event types that can require cache invalidation
var FileTreeChangeEventTypes = [...]string{
	"ITEM_COPY",
	"ITEM_CREATE",
	"ITEM_MAKE_CURRENT_VERSION",
	"ITEM_MODIFY",
	"ITEM_MOVE",
	"ITEM_RENAME",
	"ITEM_TRASH",
	"ITEM_UNDELETE_VIA_TRASH",
	"ITEM_UPLOAD",
}

// Event is an array element in the response returned from /events
type Event struct {
	EventType string `json:"event_type"`
	EventId   string `json:"event_id"`
	Source    Item   `json:"source"`
}

// Events is returned from /events
type Events struct {
	ChunkSize          int64   `json:"chunk_size"`
	Entries            []Event `json:"entries"`
	NextStreamPosition int64   `json:"next_stream_position"`
}


Review comment (suggestion):
I wonder why you are making an array `[...]string{` here rather than a slice `[]string{` - I don't think it will make any difference to anything, just wondering!

Actually having read a bit futher, the best data structure might be a map so that you can look things up in the map rather than search this list.

Eg

```go
var FileTreeChangeEventTypes = map[string]struct{}{
    "ITEM_COPY": {},
    "ITEM_CREATE": {},
```

You'd then test to see if `event` was in the map with

```go
    _, found := FileTreeChangeEventTypes[event]
```


Code after:
	PrivateKey  string `json:"privateKey"`
	Passphrase  string `json:"passphrase"`
}

// User is returned from /users/me
type User struct {
	Type          string    `json:"type"`
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	Login         string    `json:"login"`
	CreatedAt     time.Time `json:"created_at"`
	ModifiedAt    time.Time `json:"modified_at"`
	Language      string    `json:"language"`
	Timezone      string    `json:"timezone"`
	SpaceAmount   int64     `json:"space_amount"`
	SpaceUsed     int64     `json:"space_used"`
	MaxUploadSize int64     `json:"max_upload_size"`
	Status        string    `json:"status"`
	JobTitle      string    `json:"job_title"`
	Phone         string    `json:"phone"`
	Address       string    `json:"address"`
	AvatarURL     string    `json:"avatar_url"`
}

// FileTreeChangeEventTypes are the events that can require cache invalidation
var FileTreeChangeEventTypes = map[string]struct{}{
	"ITEM_COPY":                 {},
	"ITEM_CREATE":               {},
	"ITEM_MAKE_CURRENT_VERSION": {},
	"ITEM_MODIFY":               {},
	"ITEM_MOVE":                 {},
	"ITEM_RENAME":               {},
	"ITEM_TRASH":                {},
	"ITEM_UNDELETE_VIA_TRASH":   {},
	"ITEM_UPLOAD":               {},
}

// Event is an array element in the response returned from /events
type Event struct {
	EventType string `json:"event_type"`
	EventID   string `json:"event_id"`
	Source    Item   `json:"source"`
}

// Events is returned from /events
type Events struct {
	ChunkSize          int64   `json:"chunk_size"`
	Entries            []Event `json:"entries"`
	NextStreamPosition int64   `json:"next_stream_position"`
}