Ai
14 Star 50 Fork 12

Hprose/hprose-go

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
http_netrpc_cleint.go 711 Bytes
Copy Edit Raw Blame History
Hprose authored 2016-10-31 21:45 +08:00 . Update to hprose 2.0
package main
import (
"fmt"
"log"
"github.com/hprose/hprose-golang/rpc"
)
// Args ...
type Args struct {
A, B int
}
// Quotient ...
type Quotient struct {
Quo, Rem int
}
// Stub ...
type Stub struct {
// Synchronous call
Multiply func(args *Args) int
// Asynchronous call
Divide func(func(*Quotient, error), *Args)
}
func main() {
client := rpc.NewClient("http://127.0.0.1:8080")
var stub *Stub
client.UseService(&stub)
fmt.Println(stub.Multiply(&Args{8, 7}))
done := make(chan struct{})
stub.Divide(func(result *Quotient, err error) {
if err != nil {
log.Fatal("arith error:", err)
} else {
fmt.Println(result.Quo, result.Rem)
}
done <- struct{}{}
}, &Args{8, 7})
<-done
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/andot/hprose-go.git
git@gitee.com:andot/hprose-go.git
andot
hprose-go
hprose-go
v2.0.4

Search