All Projects β†’ kujtimiihoxha β†’ Gk

kujtimiihoxha / Gk

Licence: apache-2.0
Go-Kit Genetator

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gk

Samples Viewer Generator
πŸŽ‰ A CLI utility tool to generate web app of data visualization samples for presentation purpose
Stars: ✭ 13 (-90.44%)
Mutual labels:  cli, generator
Readme Md Generator
πŸ“„ CLI that generates beautiful README.md files
Stars: ✭ 9,184 (+6652.94%)
Mutual labels:  cli, generator
Rispa Cli
Modular project management
Stars: ✭ 30 (-77.94%)
Mutual labels:  cli, generator
Xcodegen
A Swift command line tool for generating your Xcode project
Stars: ✭ 5,032 (+3600%)
Mutual labels:  cli, generator
Bangajs
BΓ ngΓ‘ is a CLI generator for scaffolding ExpressJS applications with speed and efficiency.
Stars: ✭ 102 (-25%)
Mutual labels:  cli, generator
Devkit
Stars: ✭ 561 (+312.5%)
Mutual labels:  cli, generator
Guaka
The smartest and most beautiful (POSIX compliant) Command line framework for Swift πŸ€–
Stars: ✭ 1,145 (+741.91%)
Mutual labels:  cli, generator
Graphback
Graphback - Out of the box GraphQL server and client
Stars: ✭ 323 (+137.5%)
Mutual labels:  cli, generator
Generator Ngx Rocket
πŸš€ Extensible Angular 11+ enterprise-grade project generator
Stars: ✭ 1,329 (+877.21%)
Mutual labels:  cli, generator
Angular Librarian
An Angular 2+ scaffolding setup for creating libraries
Stars: ✭ 92 (-32.35%)
Mutual labels:  cli, generator
Plop
Consistency Made Simple
Stars: ✭ 4,765 (+3403.68%)
Mutual labels:  cli, generator
Genesis
Templating, scaffolding and generation tool
Stars: ✭ 122 (-10.29%)
Mutual labels:  cli, generator
Swaggen
OpenAPI/Swagger 3.0 Parser and Swift code generator
Stars: ✭ 385 (+183.09%)
Mutual labels:  cli, generator
Cfonts
Sexy fonts for the console
Stars: ✭ 789 (+480.15%)
Mutual labels:  cli, generator
Hygen
The simple, fast, and scalable code generator that lives in your project.
Stars: ✭ 4,107 (+2919.85%)
Mutual labels:  cli, generator
Telosys Cli
Telosys v 3 CLI - Command Line Interface
Stars: ✭ 66 (-51.47%)
Mutual labels:  cli, generator
Pollinate
Template your base files and generate new projects from Git(Hub).
Stars: ✭ 213 (+56.62%)
Mutual labels:  cli, generator
Extension Create
Create modern cross-browser extensions with no build configuration.
Stars: ✭ 167 (+22.79%)
Mutual labels:  cli, generator
The forge
Our groundbreaking, lightning fast PWA CLI tool
Stars: ✭ 70 (-48.53%)
Mutual labels:  cli, generator
Generact
Generate React components by replicating your own
Stars: ✭ 1,471 (+981.62%)
Mutual labels:  cli, generator

Go-Kit generator.

Go-kit generator is a cli application that generates boilerplate code for your go-kit services.

ℹ️ If you want a more advanced (but somewhat more opinionated) version of gk you can find it here. ℹ️

Why?

Because I'm lazy, and because it would make it easier for go-kit newcomers to start using it.

Installation

go get github.com/kujtimiihoxha/gk
go install github.com/kujtimiihoxha/gk

Running the generator

gk must be run from a project inside the specified $GOPATH for it to work. When it is run for the first time it will search for gk.json configuration file, if it does not find it it will create one with the default settings.

Create a new service

Inside the project run:

gk new service hello

or the shorter command:

gk n s hello

this will create a new service called HelloService inside :

project
└───hello
β”‚   └───pkg
β”‚   β”‚   └───service
β”‚   β”‚   β”‚    service.go

service.go

package service
// Implement yor service methods methods.
// e.x: Foo(ctx context.Context,s string)(rs string,err error)
type HelloService interface {
}

Now you need to add the interface methods and initiate your service: e.x:

package service
import "context"
// Implement yor service methods methods.
// e.x: Foo(ctx context.Context,s string)(rs string,err error)
type HelloService interface {
	Foo(ctx context.Context,s string)(rs string,err error)
}

than run :

gk init hello

this will create the service struct , methods, endpoints, transport .

Example GIF

The final folder structure is the same as addsvc By Default the generator will use default_transport setting from gk.json and create the transport. If you want to specify the transport use -t flag

gk init hello -t grpc

Add other transports

To add another transport to your existing service use gk add [transporteType] [serviceName]
e.x adding grpc:

gk add grpc hello

For grpc and thrift after you execute the above command you will see this message :

INFO[0000] Generating grpc transport...                 
WARN[0000] -------------------------------------------------------------------- 
WARN[0000] The service is still not ready!!             
WARN[0000] To create the grpc transport please create your protobuf. 
WARN[0000] Than follow the instructions in compile.sh and compile the .proto file. 
WARN[0000] After the file is compiled run `gk init grpc hello`. 
WARN[0000] -------------------------------------------------------------------- 

to complete the generation of the grpc transport you need to implement the protobuffer and compile it, the compile script with instructions on how to install proto is generated by gk. After you compile the protobuffer run:

gk init grpc hello

After this the handler.go file will be created and you will only need to implement the Decode/Encode of the grpc message.

Example GIF

e.x adding thrift:

gk add thrift hello

This generator will work similar as the grpc generator.

Example GIF

I don't like the folder structure!

The folder structure that the generator is using is following https://github.com/go-kit/kit/issues/70 but that can be changed using gk.json all the paths are configurable there.

Cli Help

Every command has the -h or --help flag this will give you more info on what the command does and how to use it. e.x

gk init -h

will return

Initiates a service

Usage:
  gk init [flags]

Flags:
  -t, --transport string   Specify the transport you want to initiate for the service

Global Flags:
  -d, --debug           If you want to se the debug logs.
      --folder string   If you want to specify the base folder of the project.
  -f, --force           Force overide existing files without asking.
      --testing         If testing the generator.

What is working

The example you see here https://github.com/go-kit/kit/issues/70

Examples

You can find examples under the test_dir

TODO-s

  • Implement the update commands, this commands would be used to update an existing service e.x add a new request parameter to an endpoint(Probably not needed).
  • Implement middleware generator (service,endpoint).
  • Implement automatic creation of the service main file.
  • Tests tests tests ...

Warnings

  • I only tested this on the mac, should work on other os-s but I have not tested it, I would appreciate feedback on this.

Contribute

Thanks a lot for contributing.

To test your new features/bug-fixes you need a way to run gk inside your project this can be done using test_dir.

Execute this in your command line :

export GK_FOLDER="test_dir" 

Create a folder in the gk repository called test_dir, now every time you run go run main.go [anything] gk will treat test_dir as the project root.

If you edit the templates you need to run compile.sh inside the templates folder.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].