To use GoEasyCLI, you need to have the following tools installed on your system:
Install GoEasyCLI with the following command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/OpenStruct/goeasycli/main/scripts/install.sh)"
NOTE: Please run Powershell in administrator mode.
powershell -c "irm https://raw.githubusercontent.com/OpenStruct/goeasycli/main/scripts/install.ps1 | iex"
Check available options by running:
goeasycli --help
GoEasyCLI is a command-line interface that automates project creation and setup tasks for Go projects. It streamlines the process of setting up the project structure, installing dependencies, and configuring initial settings, making it easier to start with Go.
goeasycli -p <project_name> -f {gin, fiber, echo}
Replace <project_name>
with your desired project name.
Supported frameworks:
Hereβs an example:
goeasycli -p fafa_shop_api -f fiber
This command creates a new Go project named fafa_shop_api
using the Fiber web framework.
The next step is to run your new project:
go run .
After running the project, you can explore and interact with the API using Postman. To get started quickly, import our pre-configured API requests by clicking the button below:
Remember to change the port to match your SERVER_PORT. Default is set to 8080
This Postman collection contains all available endpoints with example requests, making it easy to test and understand the APIβs functionality.
After using GoEasyCLI to create a project, the folder structure will be as follows:
βββ πfafa_shop_api
βββ .env
βββ .gitignore
βββ πconfig
βββ config.go
βββ πcontrollers
βββ health.go
βββ user.go
βββ πdatabase
βββ database.go
βββ go.mod
βββ go.sum
βββ πloggers
βββ sentry.go
βββ zap.go
βββ main.go
βββ πmiddlewares
βββ middlewares.go
βββ πmodels
βββ user.go
βββ πrouters
βββ health.go
βββ routers.go
βββ user.go
βββ πseeds
βββ seed.go
βββ πstructs
βββ structs.go
βββ πtemplates
βββ templates.go
βββ test_database.db
βββ πutils
βββ responses.go
βββ utils.go
This structure provides a solid foundation for your Go project, organized into common directories for configuration, controllers, database handling, logging, middleware, models, routes, templates, seeds, and utilities.
The config
folder contains the configuration settings for the project.
The controllers
folder contains the controller files for the project. The controller files handle the projectβs business logic.
The database
folder contains the projectβs db configuration and connection settings.
The loggers
folder contains the logger configuration settings for the project. The project uses two loggers: Zap and Sentry.
The middlewares
folder contains the middleware settings for the project.
The models
folder contains the model files for the project. The model files define the database schema for the project.
The routes
folder contains the route files for the project. The route files define the API routes for the project.
The structs
folder contains the struct files for the project. The struct files define the data structures used in the project.
The seeds
folder contains the seed files for the project. The seed files populate the database with sample data.
The templates
folder contains the template files for the project. The template files define the HTML templates used in the project.
Sometimes, you may need to render HTML templates or send emails with HTML content. In such cases, you can use the template files in this folder.
The utils
folder contains the utility files for the project. The utility files contain helper functions and utility functions used in the project.
Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub.
2024/07/17 15:10:42 C:/WINDOWS/system32/justGo/database/database.go:66
[error] failed to initialize database, got error Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub
failed to connect database
Database connection is nil. cannot run migration
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x28 pc=0x13e4992]
This error is caused by the project using SQLite
as the default database.
To fix this issue, you need to:
cmd
or powershell
:go env -w CGO_ENABLED=1
During installation, select
TDM-GCC Recommend, All Packages
from the Choose Components Screen. See Screenshot below
GoEasyCLI can also be used to create a Go library. To create a new library, use the following command:
goeasycli -l <library_name> -r repo_url
Replace <library_name>
with your desired library name and repo_url
with the repositoryβs URL.
Hereβs an example:
goeasycli -l my_awesome_fafa_lib -r https://github.com/heygoeasycli/my_awesome_fafa_lib
This command creates a new Go library named my_awesome_fafa_lib
with the specified repository URL.
The folder structure for the library will be as follows:
βββ πmy_awesome_fafa_lib
βββ .github
βββ goeasycli_tag.yml
βββ config
βββ config.go
βββ database
βββ database.go
βββ email
βββ emails.go
βββ loggers
βββ zap.go
βββ go.mod
βββ go.sum
GoEasyCLI is being built in public. The roadmap is a regularly updated source of truth for the GoEasyCLI community to understand where the product is going in the short, medium, and long term.
GoEasyCLI is managed by Open Struct, a group with the aim of easing the burden of engineers. On our GitHub repo, you can directly influence the roadmap by Creating an issue.
Need to say goodbye? We understand. Hereβs how to remove GoEasyCLI from your system. Use either of these commands in your terminal:
goeasycli -u
goeasycli uninstall
We would love to develop GoEasyCLI together with our community! The best way to get started is to select any issue from the repo and open a Pull Request!
If you find GoEasyCLI helpful or interesting, please consider giving us a star on GitHub. Your support helps promote the project and lets others know itβs worth checking out.
Thank you for being so supportive! π
GoEasyCLI is distributed under the terms of the MIT License. A complete version of the license is available in the LICENSE file in this repository. Any contribution made to this project will be licensed under the MIT License.