X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=.config%2Fcoc%2Fextensions%2Fcoc-go-data%2Ftools%2Fpkg%2Fmod%2Fgolang.org%2Fx%2Ftools%40v0.0.0-20201028153306-37f0764111ff%2Finternal%2Flsp%2Flsprpc%2Fautostart_posix.go;fp=.config%2Fcoc%2Fextensions%2Fcoc-go-data%2Ftools%2Fpkg%2Fmod%2Fgolang.org%2Fx%2Ftools%40v0.0.0-20201028153306-37f0764111ff%2Finternal%2Flsp%2Flsprpc%2Fautostart_posix.go;h=0000000000000000000000000000000000000000;hb=3ddadb3c98564791f0ac36cb39771d844a63dc91;hp=5aa0a989e2b687779904ff665bcf51c00e51e2ae;hpb=5f797af6612ed10887189b47a1efc2f915586e59;p=dotfiles%2F.git diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201028153306-37f0764111ff/internal/lsp/lsprpc/autostart_posix.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201028153306-37f0764111ff/internal/lsp/lsprpc/autostart_posix.go deleted file mode 100644 index 5aa0a989..00000000 --- a/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201028153306-37f0764111ff/internal/lsp/lsprpc/autostart_posix.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package lsprpc - -import ( - "crypto/sha256" - "errors" - "fmt" - "log" - "os" - "os/exec" - "os/user" - "path/filepath" - "strconv" - "syscall" - - "golang.org/x/xerrors" -) - -func init() { - startRemote = startRemotePosix - autoNetworkAddress = autoNetworkAddressPosix - verifyRemoteOwnership = verifyRemoteOwnershipPosix -} - -func startRemotePosix(goplsPath string, args ...string) error { - cmd := exec.Command(goplsPath, args...) - cmd.SysProcAttr = &syscall.SysProcAttr{ - Setsid: true, - } - if err := cmd.Start(); err != nil { - return xerrors.Errorf("starting remote gopls: %w", err) - } - return nil -} - -// autoNetworkAddress resolves an id on the 'auto' pseduo-network to a -// real network and address. On unix, this uses unix domain sockets. -func autoNetworkAddressPosix(goplsPath, id string) (network string, address string) { - // Especially when doing local development or testing, it's important that - // the remote gopls instance we connect to is running the same binary as our - // forwarder. So we encode a short hash of the binary path into the daemon - // socket name. If possible, we also include the buildid in this hash, to - // account for long-running processes where the binary has been subsequently - // rebuilt. - h := sha256.New() - cmd := exec.Command("go", "tool", "buildid", goplsPath) - cmd.Stdout = h - var pathHash []byte - if err := cmd.Run(); err == nil { - pathHash = h.Sum(nil) - } else { - log.Printf("error getting current buildid: %v", err) - sum := sha256.Sum256([]byte(goplsPath)) - pathHash = sum[:] - } - shortHash := fmt.Sprintf("%x", pathHash)[:6] - user := os.Getenv("USER") - if user == "" { - user = "shared" - } - basename := filepath.Base(goplsPath) - idComponent := "" - if id != "" { - idComponent = "-" + id - } - return "unix", filepath.Join(os.TempDir(), fmt.Sprintf("%s-%s-daemon.%s%s", basename, shortHash, user, idComponent)) -} - -func verifyRemoteOwnershipPosix(network, address string) (bool, error) { - if network != "unix" { - return true, nil - } - fi, err := os.Stat(address) - if err != nil { - if os.IsNotExist(err) { - return true, nil - } - return false, xerrors.Errorf("checking socket owner: %w", err) - } - stat, ok := fi.Sys().(*syscall.Stat_t) - if !ok { - return false, errors.New("fi.Sys() is not a Stat_t") - } - user, err := user.Current() - if err != nil { - return false, xerrors.Errorf("checking current user: %w", err) - } - uid, err := strconv.ParseUint(user.Uid, 10, 32) - if err != nil { - return false, xerrors.Errorf("parsing current UID: %w", err) - } - return stat.Uid == uint32(uid), nil -}