diff --git a/server/api/auth.go b/server/api/auth.go index c68c0fd..1dcc2bb 100644 --- a/server/api/auth.go +++ b/server/api/auth.go @@ -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 { diff --git a/server/api/utils.go b/server/api/utils.go index 7a097d6..d669097 100644 --- a/server/api/utils.go +++ b/server/api/utils.go @@ -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) } diff --git a/server/cmd/craban/commands/game.go b/server/cmd/craban/commands/game.go index 6747255..e92bd2e 100644 --- a/server/cmd/craban/commands/game.go +++ b/server/cmd/craban/commands/game.go @@ -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 } diff --git a/server/cmd/craban/commands/user.go b/server/cmd/craban/commands/user.go index 745f565..9f0d5cb 100644 --- a/server/cmd/craban/commands/user.go +++ b/server/cmd/craban/commands/user.go @@ -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 diff --git a/server/services/store/game.go b/server/services/store/game.go index 69c67ba..b06b94e 100644 --- a/server/services/store/game.go +++ b/server/services/store/game.go @@ -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()