https://github.com/prashantbtkl/goforge
generate entire CRUD backend for golang echo and postgres with one command
https://github.com/prashantbtkl/goforge
code-generation echo golang postgresql
Last synced: 5 months ago
JSON representation
generate entire CRUD backend for golang echo and postgres with one command
- Host: GitHub
- URL: https://github.com/prashantbtkl/goforge
- Owner: PrashantBtkl
- Created: 2024-08-11T10:44:20.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-27T11:32:47.000Z (over 1 year ago)
- Last Synced: 2025-08-25T02:22:46.288Z (10 months ago)
- Topics: code-generation, echo, golang, postgresql
- Language: Python
- Homepage:
- Size: 94.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
GoForge
[](https://pypi.org/project/goforge/)
[](https://pypi.org/project/goforge/)
[](https://pypi.org/project/goforge/)
generate the entire CRUD backend for golang echo and postgres with one command 💙
## Description
This tool is designed to start a project and edit the files later. It uses sqlc to generate all the sql related code. Make sure sqlc, goimports, gofmt, and docker are installed.
## Prerequisites
```bash
snap install sqlc
go install golang.org/x/tools/cmd/goimports@latest
```
## Installation
```bash
pip install goforge
```
## Quick start
generate the project code
```bash
$ goforge -c example.yml
```
delete the project
```bash
$ goforge -c example.yml -d
```
## API Configuration Documentation
edit the yaml as per your requirements
```yaml
project_path: "example" # specifies the root directory for the project
schema_file: "example.sql" # defines the sql schema file for the project
project_mod: "example.com/my_crud_app" # go.mod project name
db:
setup_postgres_local: true # setups a postgres docker instance for seamless testing, set false if you want to connect with your db instance
# host, port, dbname, user and password are accessed only if setup_postgres_local = false, you can skip these values if setup_postgres_local = true
host: localhost
port: 5432
dbname: postgres
user: postgres
password: postgres123
handlers:
- name: CreateUser # handler function name
path: "/v1/api/user" # api path
sql:
name: CreateUser # sqlc model method name
annotation: exec # annotations compatible with sqlc, for eg: "one", "many" and "exec"
query: "INSERT INTO users (name, email) VALUES ($1, $2)"
request:
method: "POST"
- name: GetUsers
path: "/v1/api/users"
sql:
name: GetUsers
annotation: many
query: "SELECT id, name, email FROM users LIMIT $1 OFFSET $2"
request:
method: "GET"