Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ReportUsersFile is the name of the JSON file to be created ReportUsersFile = "report.json" // FileMode is the file mode to be used when creating the JSON file FileMode = 0644 )
Variables ¶
This section is empty.
Functions ¶
func ReportUsers ¶
ReportUsers creates a JSON file with the users and snacks Returns file content is bytes an error if the file cannot be created
Types ¶
type Users ¶
type Users struct { NameUser string `json:"name"` FavSnack string `json:"favouriteSnack"` EatenSnack int64 `json:"totalSnacks"` HeapSnack map[string]int64 `json:"-"` // Emulate a Max Heap, to get the most frequent snack }
Users represents a user, his favourite snack and the number of snacks eaten
func ReadUsersFile ¶
ReadUsersFile reads a CSV file and returns a slice of users, snacks and eaten snacks The CSV file must have the following columns: name, favourite snack, total snacks Returns an error if the file cannot be read
Click to show internal directories.
Click to hide internal directories.