init
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"mcquay.me/hwt"
|
||||
)
|
||||
|
||||
const usage = "hwtc [subject]"
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", usage)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
c := hwt.NewHelloWorldProtobufClient("http://localhost:8080", &http.Client{})
|
||||
|
||||
resp, err := c.Hello(context.Background(), &hwt.HelloReq{Subject: strings.Join(os.Args[1:], " ")})
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "hello: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("%v\n", resp)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"mcquay.me/hwt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := &hwt.Server{}
|
||||
th := hwt.NewHelloWorldServer(s, nil)
|
||||
if err := http.ListenAndServe(":8080", th); err != nil {
|
||||
log.Fatalf("listen and serve: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user