- Notifications
You must be signed in to change notification settings - Fork 203
安装与使用
小马哥 edited this page Oct 31, 2016 · 1 revision
go get github.com/gorilla/websocket go get github.com/valyala/fasthttp go get github.com/hprose/hprose-golang package main import ( "net/http" "github.com/hprose/hprose-golang/rpc" ) func hello(name string) string { return "Hello " + name + "!" } func main() { service := rpc.NewHTTPService() service.AddFunction("hello", hello, rpc.Options{}) http.ListenAndServe(":8080", service) }package main import ( "fmt" "github.com/hprose/hprose-golang/rpc" ) type Stub struct { Hello func(string) (string, error) AsyncHello func(func(string, error), string) `name:"hello"` } func main() { client := rpc.NewClient("http://127.0.0.1:8080/") var stub *Stub client.UseService(&stub) stub.AsyncHello(func(result string, err error) { fmt.Println(result, err) }, "async world") fmt.Println(stub.Hello("world")) }