Categorygithub.com/awgst/gig
module
1.2.2
Repository: https://github.com/awgst/gig.git
Documentation: pkg.go.dev

# README

gig

🚀 Command line interface which provides a number helpful command to assist Go project development!

⚡️ Getting started

First, download and install Go. Then install gig by using go install command

go install github.com/awgst/gig/cmd/gig@latest

Check if gig is installed successfully

gig

Create a new project

gig create <project-name>

and it will create a new project with the following structure

.
├── cmd
│   └── seeder
│   │   └── main.go
│   └── main.go
├── database
│   └── migrations
│   │   └── 20210101000000_create_users_table.go
│   └── seeder
│   │   └── seeder.go
├── pkg
│   └── common
│   └── database
│   └── env
│   └── router
│   └── ...
├── src
│   └── app
│   └── config
│   └── routes
├── .env.example
├── .gitignore
├── Dockerfile
├── docker-compose.yml
├── gig.json
├── go.mod
├── go.sum

Set up the .env file based on the .env.example file, then you can run the project

go run cmd/main.go

or you can use the up command if you want to run the project with docker. It will run docker-compose up command

gig up

Notes: make sure you have docker installed on your machine

create your first module

gig make:module <name>

It will create a new module inside the src/app directory with the following structure

.
├── http
│   └── handler
├── model
├── repository
├── service
├── module-name.go

*Handler is a place where you can put your handler function.
*Model is a place where you can put your model struct.
*Repository is a place where you can put your repository function.
*Service is a place where you can put your service function.
*module-name.go is a place where you will create instance of handler, service and repository of your module.

If you prefered to use GORM on the first installation (you can disable it later on gig.json configuration), please to uncomment the following line in the ./pkg/database/gorm.go file based on your database

// Dialector for open connection based on driver
// Uncomment the code based on your database driver
// Run go get gorm.io/driver/{driver_name} to install the driver
// Example: go get gorm.io/driver/mysql and import "gorm.io/driver/mysql"
var dialectors = func(driver, dsn string) gorm.Dialector {
	return map[string]gorm.Dialector{
		// "mysql":      mysql.Open(dsn),
		// "postgres": postgres.Open(dsn),
	}[driver]
}

📚 Usage

create

Create a new project

gig create <name>

Arguments:

ArgumentDescriptionTypeRequired?
nameThe name of the projectstringYes

Flags:

OptionDescriptionTypeDefaultRequired?
--versionSet the specific Go version.string1.20No

make

Make file

gig make:<type> <module_name>

Arguments:

ArgumentDescriptionTypeRequired?
module_nameThe name of the projectstringYes

Types:

TypeDescription
migrationCreate a new migration
moduleCreate a new module
handlerCreate a new handler
modelCreate a new model
repositoryCreate a new repository
serviceCreate a new service
requestCreate a new request
responseCreate a new response

up

Run docker-compose up command

gig up

migrate

Run a simple database migration. Under the hood it used golang-migrate/migrate for managing database migration

gig migrate <command>

Commands:

CommandDescription
upRun migrate
downRollback migrate

To see the list of available commands, use the --help flag

gig --help

📝 License

This project is licensed under the MIT License

# Packages

Package cmd implements the list of commands that can be executed.
Package pkg implements list function and variable that can be used by other packages.
No description provided by the author