utils: remove utils & migrate code to sys

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
unclejack 2017-03-29 18:09:08 +03:00
parent 46154a6764
commit d2a6630658
5 changed files with 7 additions and 57 deletions

19
sys/socket.go Normal file
View file

@ -0,0 +1,19 @@
package sys
import (
"net"
"os"
"path/filepath"
"syscall"
)
// CreateUnixSocket creates a unix socket and returns the listener
func CreateUnixSocket(path string) (net.Listener, error) {
if err := os.MkdirAll(filepath.Dir(path), 0660); err != nil {
return nil, err
}
if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) {
return nil, err
}
return net.Listen("unix", path)
}