gorpc

command
v0.0.0-...-83adff0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

README

gorpc

说明

  1. 根据service 方法生成rpc client 以及rpc model层 代码
  2. service方法格式暂限定为以下格式
func (s *Receiver) FuncName(c context.Contex,args ...interface{}) (err error) {

}

func (s *Receiver) FuncName(c context.Contex,args ...interface{}) (resp interface{},err error) {
	
}
  1. args 参数应为基础类型,如 int,string,slice 等

使用

  1. 进入到对应目录下,执行gorpc 即可生成rpc client代码,生成的代码默认放在 project/rpc/client/ 目录下

  2. 使用-model 参数生成rpc 参数 model ,生成的代码默认放在 project/model/ 目录下

exmaple

func (s *Service) Example(c context.Contex,i int,b string)(res *Resp,err error) {
	return
}

以上代码片段将自动生成如下代码

type ArgExample struct {
	I int
	B string 
}
func (s *Service) Example(c context.Context, arg *model.ArgExample) (res *Resp, err error) {
	res = new(Resp)
	err = s.client.Call(c, _jury, arg, res)
	return
}

Documentation

Overview

A commandline tool for generating rpc code by service methods.

This tool can generate rpc client code ,rpc arg model for specific Go project dir. Usage :

$gorpc [options]

Available options:

-client   generate rpc client code.

-d        specific go project service dir (default ./service/)

-model    generate rpc arg model code.

-o        specific rpc client code output file. (default ./rpc/client/client.go)

-m        specific rpc arg model output file. (default ./model/rpc.go)

-s        print code to stdout.

Example:

$ cd $GOPATH/relation
$ gorpc
such command will generate rpc client code by functions of ./service/* and write code to $GOPATH/relation/rpc/client/client.go

Directories

Path Synopsis
Package goparse contains logic for parsing Go files.
Package goparse contains logic for parsing Go files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL