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/utenti.go

39 lines
659 B
Go

2 years ago
package website
import (
"encoding/json"
2 years ago
"os"
)
type UserInfo struct {
2 years ago
Uid string `json:"uid"`
Nome string `json:"nome"`
Cognome string `json:"cognome"`
Tags []string `json:"tags"`
IsMacchinista bool `json:"macchinista,omitempty"`
}
2 years ago
type ListaUtentiService interface {
GetUtenti() ([]UserInfo, error)
}
2 years ago
2 years ago
type JsonFileListUtenti struct {
Path string
}
2 years ago
2 years ago
func (j *JsonFileListUtenti) GetUtenti() ([]UserInfo, error) {
var users []UserInfo
2 years ago
usersJsonData, err := os.ReadFile(j.Path)
if err != nil {
return nil, err
}
if err := json.Unmarshal(usersJsonData, &users); err != nil {
return nil, err
}
return users, nil
}