// Package rpc ... // // Description : rpc ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2022-07-01 16:00 package rpc import ( "encoding/json" "fmt" "testing" ) func TestInitRPC(t *testing.T) { /*proxyServiceInfo := &Service{ Flag: "goproxy", Domain: "https://goproxy.cn/", CodeField: "-", MessageField: "-", DataField: "-", SuccessCodeList: []string{}, SuccessHttpCodeList: []int{http.StatusOK}, ApiTable: map[string]*Api{ "package_info": { Flag: "package_info", URI: "/stats/{{package_name}}", Method: http.MethodGet, BindURIParamList: []string{"package_name"}, Timeout: ApiTimeout{ Connect: 5000, Read: 5000, }, }, }, ApiRetry: ApiRetry{}, }*/ if err := InitRPCFromCfgDir("/Users/zhangdeman/project/go-project/rpc/etc", nil); nil != err { panic(err.Error()) } var result map[string]interface{} if err := Request.Send(nil, "goproxy", "package_info", map[string]interface{}{ "package_name": "golang.org/x/text", }, &result); nil != err { fmt.Println("请求出现异常 : " + err.Error()) return } byteData, _ := json.Marshal(result) fmt.Println(string(byteData)) }