natefinch / npipe

A Windows named pipe implementation written in pure Go.
MIT License
297 stars 73 forks source link

does not build on linux (expected?) #24

Closed Omortis closed 5 years ago

Omortis commented 5 years ago

Hello,

This builds and runs well on Windows 10 but produces an error on any linux install:

johnnyb@tasha:~/Projects/named/client$ go build
# _/home/johnnyb/Projects/named/client
./client.go:12:15: undefined: npipe.Dial
johnnyb@tasha:~/Projects/named/client$ cat -n client.go
     1  package main
     2
     3  import (
     4          "bufio"
     5          "fmt"
     6
     7          "gopkg.in/natefinch/npipe.v2"
     8  )
     9
    10  // Use Dial to connect to a server and read messages from it.
    11  func main() {
    12          conn, err := npipe.Dial(`\\.\pipe\mypipe`)
    13          if err != nil {
    14                  // handle error
    15          }
    16          if _, err := fmt.Fprintln(conn, "Hi server!"); err != nil {
    17                  // handle error
    18          }
    19          r := bufio.NewReader(conn)
    20          msg, err := r.ReadString('\n')
    21          if err != nil {
    22                  // handle eror
    23          }
    24          fmt.Println(msg)
    25  }

Is this expected? Since it' pure Go I was hoping it would work on both OS's. I do a fair amount of Go building on both platforms so the linux Go env is sane.

Thanks!

JB

natefinch commented 5 years ago

This is a package for windows named pipes, which uses windows syscalls to function. It can't work on linux. There are probably other packages for working with pipes on linux, but I don't at the moment know any. Sorry!

Omortis commented 5 years ago

@natefinch No problem, I was hoping to be able to get rid of a specific

if runtime.GOOS == "windows"

call. I like npipe better than tcp for an rpc callback, though, so it's still a win.

Thanks,

John

Edit: named pipes "just work" with the Go standard library on linux - FYI.