Install

Add the module, then generate the client. Go 1.18 or higher.

Add the module

The module path is github.com/lexcao/genapi. go.mod names Go 1.18.

go.modSource
module github.com/lexcao/genapi

go 1.18

From your module directory:

go get
go get github.com/lexcao/genapi

Generate the client

Put this directive on the file that declares the interface, then run go generate.

//go:generate
//go:generate go run github.com/lexcao/genapi/cmd/genapi  -file $GOFILE
go generate
go generate ./...

Inside a clone of this repository, make generate does the same job.

Optional Resty client

Resty is a separate module. Its go.mod requires Go 1.23.0.

go get
go get github.com/lexcao/genapi/pkg/clients/resty

go install

There is no go install command. The files that document installation do not contain one. Start the generator with go run, from the //go:generate line above.

Work on genapi

Installing the module does not require a clone. To change genapi, clone it:

git clone
git clone https://github.com/lexcao/genapi.git
cd genapi