Giter Club home page Giter Club logo

gen's Introduction

Gen - Tools for generating source code for microservices

Just write normal functions, and Gen generates efficient routing source code and documentation for it Because the source code is generated, none of this affects runtime performance
The differences caused by each change in the tool are shown directly in the generated source code
generating clients is also supported

Build Status Go Report Card GitHub license

Examples

'#' is the annotation, the annotation is the golang tag syntax, the only difference here is '#' wraps not '`'.

// ItemService #path:"/item/"#
type ItemService struct {}

// Create a Item #route:"POST /"#
func (s *ItemService) Create(item *Item) (err error) {}

// Update the Item #route:"PUT /{item_id}"#
func (s *ItemService) Update(itemID int /* #name:"item_id"# */, item *Item) (err error) {}

// Delete the Item #route:"DELETE /{item_id}"#
func (s *ItemService) Delete(itemID int /* #name:"item_id"# */) (err error) {}

// Get the Item #route:"GET /{item_id}"#
func (s *ItemService) Get(itemID int /* #name:"item_id"# */) (item *ItemWithID, err error) {}

// List of the Item #route:"GET /"#
func (s *ItemService) List(offset, limit int) (items []*ItemWithID, err error) {}
  1. Install gen tool go get -v github.com/wzshiming/gen/cmd/gen
  2. Add gen tool to $PATH
  3. Start it gen run github.com/wzshiming/gen-examples/service/...
  4. Open http://127.0.0.1:8080/swagger/?url=./openapi.json# with your browser

Examples

Or try to quickly build services from scratch

  1. Make a directory mkdir -p $(go env GOPATH)/src/gentest
  2. Change directory cd $(go env GOPATH)/src/gentest/
  3. Define models
cat > models.go <<EOF
package gentest
type Gentest struct {
    Name string \`json:"name"\`
    Age  int    \`json:"age"\`
}
EOF
  1. Generated from CRUD template gen crud -t mock -n Gentest
  2. Start it GO111MODULE=off gen run gentest

Supported

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

gen's People

Contributors

wzshiming avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gen's Issues

gen run basics/service error

I have follwed the examples'steps and installed the gen app. But when I run command gen run github.com/wzshiming/gen/examples/basics/service, I get error like this:

json: error calling MarshalJSON for type *spec.Response: json: error calling MarshalJSON for type *spec.Schema: json: error calling MarshalJSON for type spec.Any: unexpected end of JSON input

Can anyone tell me how can I fix this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.