chore: use errors.New to replace fmt.Errorf with no parameters will much better (#30621)

use errors.New to replace fmt.Errorf with no parameters will much better
This commit is contained in:
Cheng 2024-04-22 03:44:03 +08:00 committed by GitHub
parent f95622cddc
commit 9de443ced2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 21 additions and 15 deletions

View file

@ -4,6 +4,7 @@
package cmd
import (
"errors"
"fmt"
auth_model "code.gitea.io/gitea/models/auth"
@ -42,7 +43,7 @@ var microcmdUserGenerateAccessToken = &cli.Command{
func runGenerateAccessToken(c *cli.Context) error {
if !c.IsSet("username") {
return fmt.Errorf("You must provide a username to generate a token for")
return errors.New("You must provide a username to generate a token for")
}
ctx, cancel := installSignals()
@ -68,7 +69,7 @@ func runGenerateAccessToken(c *cli.Context) error {
return err
}
if exist {
return fmt.Errorf("access token name has been used already")
return errors.New("access token name has been used already")
}
// make sure the scopes are valid