-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
45 lines (31 loc) · 751 Bytes
/
main.go
File metadata and controls
45 lines (31 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"flag"
"fmt"
winio "github.com/Microsoft/go-winio"
)
func main() {
var name string
flag.StringVar(&name, "name", "mock", "name for the pipe")
address := "//./pipe/" + name
conn, err := winio.DialPipe(address, nil)
if err != nil {
fmt.Println("Could not connect to the selected pipe")
return
}
writeBuffer := []byte("{\"type\": nopenopenopenopenope}")
_, err = conn.Write(writeBuffer)
if err != nil {
fmt.Println("Could not send the message")
return
}
var readBuffer [4096]byte
bytesRead, err := conn.Read(readBuffer[0:])
if err != nil {
fmt.Println("Could not receive the response")
return
}
response := string(readBuffer[:bytesRead])
fmt.Println("Got response:", response)
return
}