Add gofumpt linter
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Torjus Håkestad 2022-01-27 11:36:16 +01:00
parent c6eb147e2c
commit cc4e61f981
7 changed files with 8 additions and 3 deletions

View File

@ -28,6 +28,7 @@ linters:
- stylecheck - stylecheck
- exportloopref - exportloopref
- godot - godot
- gofumpt
linters-settings: linters-settings:
gomnd: gomnd:

View File

@ -13,6 +13,7 @@ type RequestAPILogin struct {
type ResponseAPILogin struct { type ResponseAPILogin struct {
Token string `json:"token"` Token string `json:"token"`
} }
type ResponseAPIFilePost struct { type ResponseAPIFilePost struct {
Message string `json:"message"` Message string `json:"message"`
Files []ResponseAPIFilePostFiles `json:"files"` Files []ResponseAPIFilePostFiles `json:"files"`

View File

@ -58,7 +58,6 @@ func (as *AuthService) ValidateToken(rawToken string) (*Claims, error) {
token, err := jwt.ParseWithClaims(rawToken, claims, func(t *jwt.Token) (interface{}, error) { token, err := jwt.ParseWithClaims(rawToken, claims, func(t *jwt.Token) (interface{}, error) {
return as.hmacSecret, nil return as.hmacSecret, nil
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -31,6 +31,7 @@ func (c *Client) WriteConfigToWriter(w io.Writer) error {
encoder := json.NewEncoder(w) encoder := json.NewEncoder(w)
return encoder.Encode(c) return encoder.Encode(c)
} }
func (c *Client) WriteConfig() error { func (c *Client) WriteConfig() error {
dir := configdir.LocalConfig("gpaste") dir := configdir.LocalConfig("gpaste")
// Ensure dir exists // Ensure dir exists

View File

@ -23,6 +23,7 @@ func NewFSFileStore(dir string) (*FSFileStore, error) {
return s, err return s, err
} }
func (s *FSFileStore) Store(f *File) error { func (s *FSFileStore) Store(f *File) error {
defer f.Body.Close() defer f.Body.Close()

View File

@ -15,7 +15,7 @@ type BoltUserStore struct {
} }
func NewBoltUserStore(path string) (*BoltUserStore, error) { func NewBoltUserStore(path string) (*BoltUserStore, error) {
db, err := bbolt.Open(path, 0666, nil) // nolint: gomnd db, err := bbolt.Open(path, 0o666, nil) // nolint: gomnd
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -45,7 +45,6 @@ func (s *BoltUserStore) Get(username string) (*User, error) {
} }
return nil return nil
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -72,6 +71,7 @@ func (s *BoltUserStore) Delete(username string) error {
return bkt.Delete([]byte(username)) return bkt.Delete([]byte(username))
}) })
} }
func (s *BoltUserStore) List() ([]string, error) { func (s *BoltUserStore) List() ([]string, error) {
var ids []string var ids []string

View File

@ -15,6 +15,7 @@ type MemoryUserStore struct {
func NewMemoryUserStore() *MemoryUserStore { func NewMemoryUserStore() *MemoryUserStore {
return &MemoryUserStore{users: make(map[string]*User)} return &MemoryUserStore{users: make(map[string]*User)}
} }
func (s *MemoryUserStore) Get(username string) (*User, error) { func (s *MemoryUserStore) Get(username string) (*User, error) {
s.lock.Lock() s.lock.Lock()
defer s.lock.Unlock() defer s.lock.Unlock()
@ -45,6 +46,7 @@ func (s *MemoryUserStore) Delete(username string) error {
return nil return nil
} }
func (s *MemoryUserStore) List() ([]string, error) { func (s *MemoryUserStore) List() ([]string, error) {
s.lock.Lock() s.lock.Lock()
defer s.lock.Unlock() defer s.lock.Unlock()