xgen isn a tool that can help you generate a server stub for rpcx services.

It search structs in your specified files and add them as services. Currently it doesn't support registring functions.


# install
go get -u

# run
xgen -o server.go <file>.go

The above will generate server.go containing a rpcx which registers all exported struct types contained in <file>.go.


  -o string
    	specify the filename of the output
    	process the whole package instead of just the given file
  -r string
    	registry type. support etcd, consul, zookeeper, mdns (default "etcd")
  -tags string
    	build tags to add to generated file

You can run as:

xgen [options] <file1>.go <file2>.go <file3>.go 

for example, xgen -o server.go a.go b.go /User/abc/go/src/


xgen [options] <package1> <package1> <package1>

for example, xgen -o server.go