You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
website/storia.go

43 lines
835 B
Go

package main
import (
"encoding/json"
"io/ioutil"
)
type Macchinista struct {
Name string `json:"username"`
Uid string `json:"password"`
Date string `json:"date"`
Type string `json:"type"`
}
type GenericEvent struct {
Title string `json:"title"`
Description string `json:"description"`
Date string `json:"date"`
Type string `json:"type"`
}
type EventsDB struct {
Macchinisti map[string]*Macchinista `json:"macchinisti"`
GenericEvent map[string]*GenericEvent `json:"eventi,omitempty"`
}
func GetEvents() ([]EventsDB, error) {
var events []EventsDB
eventsJsonData, err := ioutil.ReadFile("./storia.json")
if err != nil {
return nil, err
}
if err := json.Unmarshal(eventsJsonData, &events); err != nil {
return nil, err
}
return events, nil
}
// TODO: Logica per ordinare gli eventi