Remove most of the checker warns
This commit is contained in:
parent
3067beb96c
commit
6aa2a94865
5 changed files with 10 additions and 12 deletions
|
@ -32,7 +32,7 @@ func (a *API) Login(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write([]byte(token))
|
_, _ = w.Write([]byte(token))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) getUserFromToken(tokenStr string) (*model.User, error) {
|
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)
|
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(tokenStr, "Bearer ") {
|
tokenStr = strings.TrimPrefix(tokenStr, "Bearer ")
|
||||||
tokenStr = tokenStr[7:]
|
|
||||||
}
|
|
||||||
|
|
||||||
user, err := a.getUserFromToken(tokenStr)
|
user, err := a.getUserFromToken(tokenStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -46,5 +46,5 @@ func JSON(w http.ResponseWriter, data interface{}, statusCode int) {
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(statusCode)
|
w.WriteHeader(statusCode)
|
||||||
w.Write(b)
|
_, _ = w.Write(b)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ func CreateGameCmd() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().StringP("owner", "o", "", "the username of the owner")
|
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.Flags().StringP("name", "n", "", "the name of the game")
|
||||||
cmd.MarkFlagRequired("name")
|
_ = cmd.MarkFlagRequired("name")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,13 @@ func CreateUserCmd() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().StringP("username", "u", "", "the username of the new user")
|
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.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.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.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")
|
cmd.Flags().BoolP("admin", "a", false, "sets the new user as an admin")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
|
@ -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)
|
return nil, fmt.Errorf("cannot get game by id: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err = gs.Q().Insert("gamemembers").
|
_, err = gs.Q().Insert("gamemembers").
|
||||||
Columns(gameMemberColumns...).
|
Columns(gameMemberColumns...).
|
||||||
Values(game.ID, userID, model.RoleGameMaster, 0).
|
Values(game.ID, userID, model.RoleGameMaster, 0).
|
||||||
Exec()
|
Exec()
|
||||||
|
|
Loading…
Reference in a new issue