diff --git a/.gitignore b/.gitignore index 91929f6..e985438 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -hwt.pb.go -hwt.twirp.go +rpc/hwt/service.pb.go +rpc/hwt/service.twirp.go vendor diff --git a/Makefile b/Makefile index 59d04a2..3ee8185 100644 --- a/Makefile +++ b/Makefile @@ -3,26 +3,26 @@ rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst default: ${GOPATH}/bin/hwtd ${GOPATH}/bin/hwtc -${GOPATH}/bin/hwtd: vendor $(call rwildcard,,*.go) hwt.go +${GOPATH}/bin/hwtd: $(call rwildcard,,*.go) hwt.go vendor @go install -v mcquay.me/hwt/cmd/hwtd -${GOPATH}/bin/hwtc: vendor $(call rwildcard,,*.go) hwt.go +${GOPATH}/bin/hwtc: $(call rwildcard,,*.go) hwt.go vendor @go install -v mcquay.me/hwt/cmd/hwtc -hwt.go: hwt.twirp.go hwt.pb.go +hwt.go: rpc/hwt/service.twirp.go rpc/hwt/service.pb.go -hwt.twirp.go: hwt.proto +rpc/hwt/service.twirp.go: rpc/hwt/service.proto @echo "generating twirp file" - @protoc --proto_path=${GOPATH}/src:. --twirp_out=. --go_out=. ./hwt.proto + @protoc --proto_path=${GOPATH}/src:. --twirp_out=. --go_out=. rpc/hwt/service.proto -hwt.pb.go: hwt.proto +rpc/hwt/service.pb.go: rpc/hwt/service.proto @echo "generating pb file" - @protoc --proto_path=${GOPATH}/src:. --twirp_out=. --go_out=. ./hwt.proto + @protoc --proto_path=${GOPATH}/src:. --twirp_out=. --go_out=. rpc/hwt/service.proto -vendor: Gopkg.toml Gopkg.lock hwt.twirp.go hwt.pb.go +vendor: Gopkg.toml Gopkg.lock dep ensure .PHONY: clean clean: - @rm -f hwt.{twirp,pb}.go + @rm -f rpc/hwt/service.{twirp,pb}.go @rm -rf vendor diff --git a/cmd/hwtc/main.go b/cmd/hwtc/main.go index fc3550f..526c9e8 100644 --- a/cmd/hwtc/main.go +++ b/cmd/hwtc/main.go @@ -7,7 +7,7 @@ import ( "os" "strings" - "mcquay.me/hwt" + pb "mcquay.me/hwt/rpc/hwt" ) const usage = "hwtc [subject]" @@ -18,9 +18,9 @@ func main() { os.Exit(1) } - c := hwt.NewHelloWorldProtobufClient("http://localhost:8080", &http.Client{}) + c := pb.NewHelloWorldProtobufClient("http://localhost:8080", &http.Client{}) - resp, err := c.Hello(context.Background(), &hwt.HelloReq{Subject: strings.Join(os.Args[1:], " ")}) + resp, err := c.Hello(context.Background(), &pb.HelloReq{Subject: strings.Join(os.Args[1:], " ")}) if err != nil { fmt.Fprintf(os.Stderr, "hello: %v\n", err) os.Exit(1) diff --git a/cmd/hwtd/main.go b/cmd/hwtd/main.go index fdb5b31..aac9e4a 100644 --- a/cmd/hwtd/main.go +++ b/cmd/hwtd/main.go @@ -5,11 +5,12 @@ import ( "net/http" "mcquay.me/hwt" + pb "mcquay.me/hwt/rpc/hwt" ) func main() { s := &hwt.Server{} - th := hwt.NewHelloWorldServer(s, nil) + th := pb.NewHelloWorldServer(s, nil) if err := http.ListenAndServe(":8080", th); err != nil { log.Fatalf("listen and serve: %v", err) } diff --git a/hwt.go b/hwt.go index fffc3de..f71525f 100644 --- a/hwt.go +++ b/hwt.go @@ -3,10 +3,12 @@ package hwt import ( "context" fmt "fmt" + + pb "mcquay.me/hwt/rpc/hwt" ) type Server struct{} -func (s *Server) Hello(ctx context.Context, req *HelloReq) (*HelloResp, error) { - return &HelloResp{Text: fmt.Sprintf("echo: %v", req.Subject)}, nil +func (s *Server) Hello(ctx context.Context, req *pb.HelloReq) (*pb.HelloResp, error) { + return &pb.HelloResp{Text: fmt.Sprintf("echo: %v", req.Subject)}, nil } diff --git a/hwt.proto b/rpc/hwt/service.proto similarity index 100% rename from hwt.proto rename to rpc/hwt/service.proto