Files
greenlight/internal/data/movies.go
Maxime Delporte bc21c4cf87
All checks were successful
Deploy Greenlight API / deploy (push) Successful in 54s
Use Runtime type instead of int32 in our Movie struct.
2025-10-21 16:29:11 +02:00

22 lines
718 B
Go

package data
import "time"
// Movie
/*
Annotate the Movie struct with struct tags to control how the keys
appear in the JSON-encoded output.
*/
type Movie struct {
ID int64 `json:"id"`
CreatedAt time.Time `json:"-"`
Title string `json:"title"`
Year int32 `json:"year,omitempty"`
/*
Use the Runtime type instead of int32. Note that the omitempty directive will still work on this: if the Runtime field has the underlying value 0, then it will be considered empty and omitted -- and the MarshalJSON() method we just made won't be called at all.
*/
Runtime Runtime `json:"runtime,omitempty,string"`
Genres []string `json:"genres,omitempty"`
Version int32 `json:"version"`
}