Remove most of the checker warns

This commit is contained in:
Miguel de la Cruz 2021-09-25 17:32:37 +02:00
parent 3067beb96c
commit 6aa2a94865
5 changed files with 10 additions and 12 deletions

View file

@ -32,7 +32,7 @@ func (a *API) Login(w http.ResponseWriter, r *http.Request) {
return
}
w.Write([]byte(token))
_, _ = w.Write([]byte(token))
}
func (a *API) getUserFromToken(tokenStr string) (*model.User, error) {
@ -71,9 +71,7 @@ func (a *API) Secured(fn func(http.ResponseWriter, *http.Request)) func(http.Res
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
return
}
if strings.HasPrefix(tokenStr, "Bearer ") {
tokenStr = tokenStr[7:]
}
tokenStr = strings.TrimPrefix(tokenStr, "Bearer ")
user, err := a.getUserFromToken(tokenStr)
if err != nil {

View file

@ -46,5 +46,5 @@ func JSON(w http.ResponseWriter, data interface{}, statusCode int) {
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(statusCode)
w.Write(b)
_, _ = w.Write(b)
}

View file

@ -32,9 +32,9 @@ func CreateGameCmd() *cobra.Command {
}
cmd.Flags().StringP("owner", "o", "", "the username of the owner")
cmd.MarkFlagRequired("owner")
_ = cmd.MarkFlagRequired("owner")
cmd.Flags().StringP("name", "n", "", "the name of the game")
cmd.MarkFlagRequired("name")
_ = cmd.MarkFlagRequired("name")
return cmd
}

View file

@ -33,13 +33,13 @@ func CreateUserCmd() *cobra.Command {
}
cmd.Flags().StringP("username", "u", "", "the username of the new user")
cmd.MarkFlagRequired("username")
_ = cmd.MarkFlagRequired("username")
cmd.Flags().StringP("password", "p", "", "the password of the new user")
cmd.MarkFlagRequired("password")
_ = cmd.MarkFlagRequired("password")
cmd.Flags().StringP("name", "n", "", "the name of the new user")
cmd.MarkFlagRequired("name")
_ = cmd.MarkFlagRequired("name")
cmd.Flags().StringP("mail", "m", "", "the mail of the new user")
cmd.MarkFlagRequired("mail")
_ = cmd.MarkFlagRequired("mail")
cmd.Flags().BoolP("admin", "a", false, "sets the new user as an admin")
return cmd

View file

@ -104,7 +104,7 @@ func (gs *GameStore) Create(name string, userID int) (*model.Game, error) {
return nil, fmt.Errorf("cannot get game by id: %w", err)
}
res, err = gs.Q().Insert("gamemembers").
_, err = gs.Q().Insert("gamemembers").
Columns(gameMemberColumns...).
Values(game.ID, userID, model.RoleGameMaster, 0).
Exec()