pb2tarsgo

    • Add tarsrpc plugin for protoc-gen-go
    1. go build .
    2. cp protoc-gen-go $GOPATH/bin
    3. export PATH=$PATH:$GOPATH/bin

    示例

    • proto 文件
    • 生成代码
    1. protoc --go_out=plugins=tarsrpc:. helloworld.proto
    • 客户端
    1. package main
    2. import (
    3. "github.com/TarsCloud/TarsGo/tars"
    4. "helloworld"
    5. )
    6. func main() {
    7. obj := fmt.Sprintf("StressTest.HelloPbServer.GreeterTestObj@tcp -h 127.0.0.1 -p 10014 -t 60000")
    8. comm.StringToProxy(obj, app)
    9. input := helloworld.HelloRequest{Name: "sandyskies"}
    10. output, err := app.SayHello(input)
    11. if err != nil {
    12. fmt.Println("err: ", err)
    13. }
    14. fmt.Println("result is:", output.Message)