We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Here is my code, please check it out.
package main import ( "bytes" "fmt" "log" "os" "os/exec" "strconv" kdb "github.com/sv/kdbgo" ) var testPort = 0 func StartQ(ready chan struct{}) { fmt.Println("Starting q process on random port") _, err := exec.LookPath("q") if err != nil { log.Fatal("installing q is in your future") } cmd := exec.Command("q", "-p", "0W", "-q") stdin, err := cmd.StdinPipe() if err != nil { log.Fatal("Failed to connect stdin", err) } stdin.Write([]byte(".z.pi:.z.pg:.z.ps:{value 0N!x};system\"p\"\n")) stdout, err := cmd.StdoutPipe() if err != nil { log.Fatal("Failed to connect stdout", err) } stderr, err := cmd.StderrPipe() if err != nil { log.Fatal("Failed to connect stderr", err) } err = cmd.Start() if err != nil { log.Fatal("Failed to start q", err) } buf := make([]byte, 16) n, err := stdout.Read(buf) if err != nil { log.Fatal("Failed to fill port number for child process: ", err) } testPort, err = strconv.Atoi(string(buf[:bytes.IndexByte(buf, 'i')])) if err != nil { fmt.Println("Failed to setup listening port", string(buf[:n]), err) cmd.Process.Kill() os.Exit(1) } fmt.Println("Listening port is ", testPort) go func() { for { buf := make([]byte, 256) n, err := stderr.Read(buf) fmt.Println("Q stderr output:", string(buf[:n])) if err != nil { fmt.Println("Q stderr error:", err) return } } }() go func() { for { buf := make([]byte, 256) _, err := stdout.Read(buf) //fmt.Println("Q stdout output:", string(buf[:n])) if err != nil { fmt.Println("Q stdout error:", err) return } } }() ready <- struct{}{} cmd.Wait() //stdin.Write([]byte("show `exiting_process;\nexit 0\n")) } func main() { ready := make(chan struct{}) go StartQ(ready) <-ready log.Println("Connect to kdb+ through unix socket.") con, err := kdb.DialUnix("localhost", testPort, "") if err != nil { panic(err) } log.Println("Close the connection") err = con.Close() if err != nil { panic(err) } }
The text was updated successfully, but these errors were encountered:
What is the error you get from DialUnix?
Sorry, something went wrong.
No branches or pull requests
Here is my code, please check it out.
The text was updated successfully, but these errors were encountered: