Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unix sockets on windows #1637

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions os_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os/user"
"path/filepath"
"strings"
"syscall"

"golang.org/x/sys/windows"
)
Expand All @@ -24,8 +25,8 @@ var envPathExt = os.Getenv("PATHEXT")
var (
gDefaultShell = "cmd"
gDefaultShellFlag = "/c"
gDefaultSocketProt = "tcp"
gDefaultSocketPath = "127.0.0.1:12345"
gDefaultSocketProt = "unix"
gDefaultSocketPath string
)

var (
Expand Down Expand Up @@ -94,6 +95,15 @@ func init() {
filepath.Join(data, "lf", "icons"),
}

socket, err := syscall.Socket(syscall.AF_UNIX, syscall.SOCK_STREAM, 0)
if err != nil {
gDefaultSocketProt = "tcp"
gDefaultSocketPath = "127.0.0.1:12345"
} else {
gDefaultSocketPath = filepath.Join(data, "lf", fmt.Sprintf("lf.%s.sock", gUser.Username))
syscall.Close(socket)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly pedantic, but I suggest to move this to the bottom of the init function after the path definitions, to maintain the same order as os.go.

gFilesPath = filepath.Join(data, "lf", "files")
gMarksPath = filepath.Join(data, "lf", "marks")
gTagsPath = filepath.Join(data, "lf", "tags")
Expand Down
Loading