diff --git a/.golangci.yml b/.golangci.yml index 105af5a..d8da413 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -28,6 +28,7 @@ linters: - stylecheck - exportloopref - godot + - gofumpt linters-settings: gomnd: diff --git a/api/json.go b/api/json.go index 5059ec5..0aade56 100644 --- a/api/json.go +++ b/api/json.go @@ -13,6 +13,7 @@ type RequestAPILogin struct { type ResponseAPILogin struct { Token string `json:"token"` } + type ResponseAPIFilePost struct { Message string `json:"message"` Files []ResponseAPIFilePostFiles `json:"files"` diff --git a/auth.go b/auth.go index f4e403b..a720d27 100644 --- a/auth.go +++ b/auth.go @@ -58,7 +58,6 @@ func (as *AuthService) ValidateToken(rawToken string) (*Claims, error) { token, err := jwt.ParseWithClaims(rawToken, claims, func(t *jwt.Token) (interface{}, error) { return as.hmacSecret, nil }) - if err != nil { return nil, err } diff --git a/client/client.go b/client/client.go index 18ba019..1958972 100644 --- a/client/client.go +++ b/client/client.go @@ -31,6 +31,7 @@ func (c *Client) WriteConfigToWriter(w io.Writer) error { encoder := json.NewEncoder(w) return encoder.Encode(c) } + func (c *Client) WriteConfig() error { dir := configdir.LocalConfig("gpaste") // Ensure dir exists diff --git a/files/filestore_fs.go b/files/filestore_fs.go index 0c9491b..8d9e996 100644 --- a/files/filestore_fs.go +++ b/files/filestore_fs.go @@ -23,6 +23,7 @@ func NewFSFileStore(dir string) (*FSFileStore, error) { return s, err } + func (s *FSFileStore) Store(f *File) error { defer f.Body.Close() diff --git a/users/userstore_bolt.go b/users/userstore_bolt.go index c67b704..8ad11e7 100644 --- a/users/userstore_bolt.go +++ b/users/userstore_bolt.go @@ -15,7 +15,7 @@ type BoltUserStore struct { } 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 { return nil, err } @@ -45,7 +45,6 @@ func (s *BoltUserStore) Get(username string) (*User, error) { } return nil }) - if err != nil { return nil, err } @@ -72,6 +71,7 @@ func (s *BoltUserStore) Delete(username string) error { return bkt.Delete([]byte(username)) }) } + func (s *BoltUserStore) List() ([]string, error) { var ids []string diff --git a/users/userstore_memory.go b/users/userstore_memory.go index f21bc6c..763e237 100644 --- a/users/userstore_memory.go +++ b/users/userstore_memory.go @@ -15,6 +15,7 @@ type MemoryUserStore struct { func NewMemoryUserStore() *MemoryUserStore { return &MemoryUserStore{users: make(map[string]*User)} } + func (s *MemoryUserStore) Get(username string) (*User, error) { s.lock.Lock() defer s.lock.Unlock() @@ -45,6 +46,7 @@ func (s *MemoryUserStore) Delete(username string) error { return nil } + func (s *MemoryUserStore) List() ([]string, error) { s.lock.Lock() defer s.lock.Unlock()