Code Monkey home page Code Monkey logo

gen-golang's Introduction

webrpc-gen Golang templates

This repo contains the templates used by the webrpc-gen cli to code-generate webrpc Go server and client code.

Usage

webrpc-gen -schema=example.ridl -target=golang -out=./example.gen.go -pkg=main -server -client

# or 
webrpc-gen -schema=example.ridl -target=github.com/webrpc/[email protected] -out=./example.gen.go -pkg=main -server -client

# or
webrpc-gen -schema=example.ridl -target=./local-go-templates-on-disk -out=./example.gen.go -pkg=main -server -client

As you can see, the -target supports default golang, any git URI, or a local folder :)

Set custom template variables

Change any of the following values by passing -option="Value" CLI flag to webrpc-gen.

webrpc-gen -option Description Default value
-pkg=<name> package name "proto"
-client generate client code unset (false)
-server generate server code unset (false)

Example:

webrpc-gen -schema=./proto.json -target=golang -out openapi.gen.yaml -pkg=main -client -server

Set custom Go field meta tags in your RIDL file

CLI option flag Description
+ go.field.name = ID Set custom field name
+ go.field.type = int64 Set custom field type (must be able to JSON unmarshal the value)
+ go.tag.json = id Set json:"id" struct tag
+ go.tag.db = id Set db:"id" struct tag

Example:

message User
  - id: uint64
    + go.field.name = ID
    + go.tag.db = id
    + go.tag.json = id

will result in

type User struct {
	ID uint64 `json:"id" db:"id"`
}

Examples

See _examples

LICENSE

MIT LICENSE

gen-golang's People

Contributors

paulxuca avatar pkieltyka avatar vojtechvitek avatar xiam avatar

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.