tree: c6fe8e0d72e8f275993d6af3ab315da96ad81e0e [path history] [tgz]
  1. go-client/
  2. go-server/
  3. proto/
  4. README.md
helloworld/README.md

Helloworld for dubbo-go

This example demonstrates the basic usage of dubbo-go as an RPC framework. Check Quick Start on our official website for detailed explanation.

Contents

  • go-server/cmd/main.go - is the main definition of the service, handler and rpc server
  • go-client/cmd/main.go - is the rpc client
  • proto - contains the protobuf definition of the API

How to run

Prerequisites

  1. Install `protoc version3 Please refer to Protocol Buffer Compiler Installation.

  2. Install protoc-gen-go and protoc-gen-triple Install the version of your choice of protoc-gen-go. here use the latest version as example:

    go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31
    

    Install the latest version of protoc-gen-triple:

    go install dubbo.apache.org/dubbo-go/v3/cmd/protoc-gen-go-triple@v3.0.1
    
  3. Generate stub code

    Generate related stub code with protoc-gen-go and protoc-gen-go-triple:

    protoc --go_out=. --go_opt=paths=source_relative --go-triple_out=. --go-triple_opt=paths=source_relative ./proto/greet.proto
    

Run server

go run ./go-server/cmd/main.go

test server work as expected:

curl \
    --header "Content-Type: application/json" \
    --data '{"name": "Dubbo"}' \
    http://localhost:20000/greet.GreetService/Greet

Run client

go run ./go-client/cmd/main.go