Skip to content

dung13890/go-base-gen

Repository files navigation

go-base-gen

workflow status License: MIT

Overview

Command line tool to generate a project from a template. It is a tool that helps you to init code base and start a new project quickly.

NAME:
   go-base-gen - Use this tool to generate base code

USAGE:
   go-base-gen [global options] command [command options] [arguments...]

VERSION:
   v1.0.10

COMMANDS:
   project  Generate base code for go project use clean architecture
   domain   Create new domain in project
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print only the version (default: false)

Features

  • Generate project base on clean architecture
  • Generate module

Installation

go install github.com/dung13890/go-base-gen@latest

Usage

  • Init Project base on clean architecture
## Short
go-base-gen project -n <project-name>

## Long
go-base-gen project --name <project-name> --path <project-path>
  • Create new domain
## Short
go-base-gen domain -n <domain-name> -pj <project-name> -m <module-name>

## Long
go-base-gen domain --name <domain-name> --project <project-name> --module <module-name> --path <project-path>
  • Example usage
# Genenrate project-demo
go-base-gen project -n project-demo

# cd to project-demo
cd project-demo/

# download dependencies
go mod tidy

# create env file
cp .env.example .env

# setup database
go run cmd/migrate/main.go 
go run cmd/seed/main.go

# create domain product in module ecommerce
go-base-gen domain -n product -pj project-demo -m ecommerce

# Run project for development
make dev

Structure project after generate

.
├── cmd
│   ├── app
│   ├── migrate
│   └── seed
├── config
├── db
│   ├── migrations
│   └── seeds
├── internal
│   ├── app
│   ├── constants
│   ├── domain
│   ├── impl
│   │   ├── pubsub
│   │   └── service
│   ├── modules
│   │   └── auth
│   │   │   ├── delivery
│   │   │   ├── repository
│   │   │   └── usecase
│   └── registry
└── pkg

You can see more detail in go-clean-architecture

"Buy Me A Coffee"