Avoid Atoi to avoid int convertion

This commit is contained in:
nemunaire 2018-12-01 16:15:28 +01:00
commit 0f48b27a04
11 changed files with 32 additions and 39 deletions

View file

@ -59,13 +59,9 @@ func GetEvents() ([]Event, error) {
}
// GetEvent retrieves the event with the given id
func GetEvent(id int) (Event, error) {
var e Event
if err := DBQueryRow("SELECT id_event, txt, kind, time FROM events WHERE id_event=?", id).Scan(&e.Id, &e.Text, &e.Kind, &e.Time); err != nil {
return e, err
}
return e, nil
func GetEvent(id int64) (e Event, err error) {
err = DBQueryRow("SELECT id_event, txt, kind, time FROM events WHERE id_event=?", id).Scan(&e.Id, &e.Text, &e.Kind, &e.Time)
return
}
// NewEvent creates a new event in the database and returns the corresponding structure

View file

@ -161,12 +161,9 @@ func (e *Exercice) FixURLId() bool {
}
// GetThemeId returns the theme's id for the Exercice.
func (e Exercice) GetThemeId() (int, error) {
var tid int
if err := DBQueryRow("SELECT id_theme FROM exercices WHERE id_exercice=?", e.Id).Scan(&tid); err != nil {
return 0, err
}
return tid, nil
func (e Exercice) GetThemeId() (tid int64, err error) {
err = DBQueryRow("SELECT id_theme FROM exercices WHERE id_exercice=?", e.Id).Scan(&tid)
return
}
// GetTheme returns the parent Theme where the Exercice lives.

View file

@ -67,9 +67,9 @@ func GetFiles() ([]EFile, error) {
}
// GetFile retrieves the file with the given id.
func GetFile(id int) (f EFile, err error) {
func GetFile(id int64) (f EFile, err error) {
err = DBQueryRow("SELECT id_file, origin, path, name, cksum, size FROM exercice_files WHERE id_file = ?", id).Scan(&f.Id, &f.origin, &f.Path, &f.Name, &f.Checksum, &f.Size)
return f, err
return
}
// GetFileByPath retrieves the file that should be found at the given location.

View file

@ -40,7 +40,7 @@ func (f Flag) GetChoices() ([]FlagChoice, error) {
}
// GetChoice returns a choice for the given Flag.
func (f Flag) GetChoice(id int) (c FlagChoice, err error) {
func (f Flag) GetChoice(id int64) (c FlagChoice, err error) {
if errr := DBQueryRow("SELECT id_choice, id_flag, label, response FROM flag_choices WHERE id_choice = ?", id).Scan(&c.Id, &c.IdFlag, &c.Label, &c.Value); errr != nil {
return c, errr
}

View file

@ -37,7 +37,7 @@ type myTeamFlag struct {
Choices map[string]string `json:"choices,omitempty"`
}
type myTeamExercice struct {
ThemeId int `json:"theme_id"`
ThemeId int64 `json:"theme_id"`
Statement string `json:"statement"`
Overview string `json:"overview,omitempty"`
Hints []myTeamHint `json:"hints,omitempty"`

View file

@ -37,7 +37,7 @@ func GetThemes() ([]Theme, error) {
}
// GetTheme retrieves a Theme from its identifier.
func GetTheme(id int) (Theme, error) {
func GetTheme(id int64) (Theme, error) {
var t Theme
if err := DBQueryRow("SELECT id_theme, name, url_id, path, authors, intro, image FROM themes WHERE id_theme=?", id).Scan(&t.Id, &t.Name, &t.URLId, &t.Path, &t.Authors, &t.Intro, &t.Image); err != nil {
return t, err

View file

@ -17,7 +17,7 @@ type Claim struct {
}
// GetClaim retrieves the claim with the given identifier.
func GetClaim(id int) (c Claim, err error) {
func GetClaim(id int64) (c Claim, err error) {
err = DBQueryRow("SELECT id_claim, subject, id_team, id_assignee, creation, state, priority FROM claims WHERE id_claim = ?", id).Scan(&c.Id, &c.Subject, &c.IdTeam, &c.IdAssignee, &c.Creation, &c.State, &c.Priority)
return
}