kite

command module
v0.0.0-...-4f71f7c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2022 License: MIT Imports: 0 Imported by: 0

README

What it is

Kite is a golang project structure's code generation that build the base project and provide tools to help for creating a new projects

Installation

Clone this repo

git clone https://github.com/nurcahyaari/kite.git

then open the directory in your terminal app.

go build kite.go

The app was built as binary. then move the binary app into your $PATH environment

How to use

This following bash script is the example to generate project using Kite

Command Function
kite new --name Create new application/ project/ service
main module --name creating new modules such as, product modules, user modules, auth modules, etc

creating new applications

after you have done to setup your binary of kite in your environtment $PATH you can use kite to create your new applications

command

kite new --args1 value --args2 value
args function
name your application name
path your application path

example, I created new Backend service for my apps called as Todo-Backend. and I want to save this service at my Documents package /usr/Documents

  1. First I can use command cd to go to /usr/Documents
  2. Or I can use the path args in kite generation command
kite new --name Todo-Backend --path /usr/Documents

After I've created my Backend I must create my Modules first

creating your new modules

because when you create your new apps, currently the generator will not create your first module. you must to create your modules to determines that your service working

command

kite module --args1 value --args2 value
args function
name your module name
path your application path

The module name is Test and it is under of my Todo-Backend so I will use this command

kite module --name Test --path --value /usr/Documents/Todo-Backend

because, Kite still doesn't support to auto adding modules into wire.go. after adding the new modules you must manually inject your modules and any others dependencies into wire.go manually.

after you create your new project, and your new module then you must:

  1. add your handlers into internal/protocols/http/router/route.go
  2. add package src/handlers/http into protocols/http/http.go, it should be look like this
package router

import (
	"github.com/go-chi/chi/v5"
	"Todo-Backend/src/handlers/http"
)

type HttpRouterImpl struct {
	httpHandlers http.HttpHandler
}

func NewHttpRouter(httpHandlers http.HttpHandler) *HttpRouterImpl {
	return &HttpRouterImpl{
		httpHandlers: httpHandlers,
	}
}
func (h *HttpRouterImpl) Router(r *chi.Mux) {
	h.httpHandlers.Router(r)
}

  1. add your new modules into wire.go

first you must add into your import package

add your test module's repo testrepo "Todo-Backend/src/modules/test/repository"

add your test module's service testsvc "Todo-Backend/src/modules/test/service"

var testRepo = wire.NewSet(
	testrepo.NewTestRepository,
	wire.Bind(
		new(testrepo.TestRepository),
		new(*testrepo.TestRepositoryImpl),
	),
)

var testSvc = wire.NewSet(
	testsvc.NewTestService,
	wire.Bind(
		new(testsvc.TestService),
		new(*testsvc.TestServiceImpl),
	),
)

and add into domain variables in wire.go

var domain = wire.NewSet(
	testSvc,
)
  1. run go generate ./...
  2. copy your .env.example into .env
  3. if you've got an error, install the package that needed in your project
  4. run your project with this command go run main.go wire_gen.go

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL