GoXpress
GoXpress provides an intuitive architecture for Go server projects, designed to facilitate rapid development of your API applications. It is bundled with variety of framework and packages to streamline your development process. While this setup is comprehensive, you are not required to utilize all included packages. Feel free to use this repository as a reference to tailor your project according to your specific needs.
| Stack |
Package |
Go v1.25.0 |
Echo v5.1.0 |
Air v1.64.5 |
Gorm v1.31.1 |
| Postgres |
EchoSwagger v2.0.1 |
| Docker |
|
Pre-Build Functions
- Easy development with Air hot-reload
- Easy deployment with docker
- Gorm with postgres connection
- Initial user table and user model
- Request params validation
- Register/Login password encryption
- Simple Jwt bearer token and authentication middleware
- Default docs page and auth & sample user routes
- Swagger api documentation (not auto generated)
- Simple docker containerize
Getting started
Installation
- Ensure that Golang 1.25.0 is installed on system.
- Go into project folder. (Linux Example: /www)
cd wwww
go run github.com/xncs120/goxpress@main project_name
Setting up enviroment configs
- Modify .env as necessary to suit your configuration requirements. There are several important key:
- APP_ENV accept "development" / "production".
- JWT_SECRET_KEY accept string generated with 256BITS_HMAC_ALGO_HS256 format.
- DB_URL accept string for database connection (postgres). For other database support please visit gorm documentation.
Migration
- Database migration is in /main.go > db.Migration() that is commented. Uncomment it to use Gorm auto migrate function.
- Remember to add any model struct to /db/migration.go whenever creating a new table for auto migrate to work.
Serve api
- Go into generated project folder and run command below.
- Access on api browser http://localhost:8080/ or http://localhost:8080/docs after success.
- The docs page title wont change to project_name, feel free to admend it in /views/index.html.
cd project_name
air -c air.toml
Deploy with docker
# check did docker get .env values
docker-compose --env-file .env config
# build docker contianer
docker compose --env-file .env up --build
Project layout (Default)
project_name/
├── client/ (frontend js framework)
├── config/
│ ├── app.go
│ ├── config.go
│ └── database.go
├── db/
│ ├── db.go
│ └── migration.go (auto migration)
├── handlers/
│ ├── auth.go
│ ├── landing.go
│ └── user.go
├── internal/ (any important function)
│ ├── request/
│ │ └── validator.go
│ └── security/
│ ├── password.go
│ └── token.go
├── models/
│ └── user.go (gorm struct or other gobal used struct)
├── router/
│ ├── api.go
│ ├── router.go
│ └── web.go
├── server/
│ └── main.go (server trigger)
├── views/ (frontend html)
│ ├── docs.go (swagger documentation)
│ │ └── root.yaml
│ ├── efs.go
│ └── index.html (homepage)
├── .env (server config)
├── .gitignore
├── air.toml (air config)
├── docker-compose.yaml
├── Dockerfile
├── go.mod
└── go.sum
Reference and external source