Skip to content

Commit 257bc2f

Browse files
fix: ignore os.IsNotExist error when removing stale UNIX socket (#316)
* fix: ignore os.IsNotExist error when removing stale UNIX socket * fix: remove comment for unused linter "nakedret" * fix: directly call os.Remove
1 parent 3c0843c commit 257bc2f

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

api/make_listener_posix.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ func makeListener(cfg Config) (net.Listener, error) {
4747
}
4848

4949
if network == unixNetwork {
50-
if _, err := os.Stat(path); !os.IsNotExist(err) {
51-
if err := os.Remove(path); err != nil {
52-
return nil, fmt.Errorf("cannot remove existing unix socket file at location %s: %w", path, err)
53-
}
50+
if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
51+
return nil, fmt.Errorf("cannot remove existing unix socket file at location %s: %w", path, err)
5452
}
5553
}
5654

api/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (s *Server) AttachHandler(route string, h http.Handler) (err error) {
123123
}()
124124
s.log.Infof("Attempting to attach %q to server.", route)
125125
s.mux.Handle(route, h)
126-
return //nolint:nakedret // returning from recover
126+
return // returning from recover
127127
}
128128

129129
func parse(host string, port int) (string, string, error) {

0 commit comments

Comments
 (0)