hwt/cmd/hwtc/main.go

32 lines
585 B
Go
Raw Normal View History

2018-01-16 20:57:04 -08:00
package main
import (
"context"
"fmt"
"net/http"
"os"
"strings"
pb "mcquay.me/hwt/rpc/hwt"
2018-01-16 20:57:04 -08:00
)
2018-01-20 08:49:02 -08:00
const usage = "hwtc <server address> [subject]"
2018-01-16 20:57:04 -08:00
func main() {
2018-01-20 08:49:02 -08:00
if len(os.Args) < 3 {
2018-01-16 20:57:04 -08:00
fmt.Fprintf(os.Stderr, "%v\n", usage)
os.Exit(1)
}
2018-01-20 08:49:02 -08:00
c := pb.NewHelloWorldProtobufClient(fmt.Sprintf("http://%s", os.Args[1]), &http.Client{})
2018-01-16 20:57:04 -08:00
2018-01-21 20:12:05 -08:00
for i := 0; ; i++ {
resp, err := c.Hello(context.Background(), &pb.HelloReq{Subject: strings.Join(os.Args[2:], " ")})
if err != nil {
fmt.Fprintf(os.Stderr, "hello: %#v\n", err)
os.Exit(1)
}
fmt.Printf("0x%08x: %#v\n", i, resp)
2018-01-16 20:57:04 -08:00
}
}