Supabase toolkit for Go projects.
go install github.com/01JAMIL/supago.git/cmd/supago@latestsupago init
# configure .env with your database URL (SUPAGO_DATABASE_URL)
supago generate allGiven a database with users and tasks tables, supago generate all produces:
internal/
├── adapters/
│ └── supago/
│ ├── models.go # All Go structs
│ ├── users/
│ │ └── repository.go # Repository implementation
│ └── tasks/
│ └── repository.go # Repository implementation
├── users/
│ ├── service.go # Business logic (starting point)
│ └── handler.go # HTTP handlers (starting point)
├── tasks/
│ ├── service.go # Business logic (starting point)
│ └── handler.go # HTTP handlers (starting point)
└── json/
└── json.go # JSON helpers (generated, DO NOT EDIT)
// internal/adapters/supago/models.go
package supago
type User struct {
ID int64 `json:"id"`
FullName *string `json:"fullName"`
Email *string `json:"email"`
CreatedAt time.Time `json:"createdAt"`
}
type Task struct {
ID int64 `json:"id"`
TaskName *string `json:"taskName"`
IsDone *bool `json:"isDone"`
UserID *int64 `json:"userId"`
CreatedAt time.Time `json:"createdAt"`
}// internal/adapters/supago/users/repository.go
package users
type Repository struct {
pool *pgxpool.Pool
}
func NewRepository(pool *pgxpool.Pool) *Repository { ... }
func (r *Repository) List(ctx context.Context) ([]supago.User, error) { ... }
func (r *Repository) GetByID(ctx context.Context, id int64) (*supago.User, error) { ... }
func (r *Repository) Create(ctx context.Context, user *supago.User) error { ... }
func (r *Repository) Update(ctx context.Context, user *supago.User) error { ... }
func (r *Repository) Delete(ctx context.Context, id int64) error { ... }// internal/users/service.go — starting point, modify as needed
package users
type Service struct {
repo *usersrepo.Repository
}
func (s *Service) List(ctx context.Context) ([]supago.User, error) {
return s.repo.List(ctx)
}// internal/users/handler.go — starting point, modify as needed
func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
items, err := h.svc.List(r.Context())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
json.Write(w, http.StatusOK, items)
}| Layer | Path | Ownership |
|---|---|---|
| Infrastructure | internal/adapters/supago/ |
Generated by SupaGo, DO NOT EDIT |
| Application | internal/{table}/ |
Generated as starting point, modify freely |
The infrastructure layer owns the models and repository implementations. The application layer owns the services and handlers — generated once as a starting point, then fully owned by the developer.
supago.yaml is generated by supago init:
version: 1
database:
driver: postgres
url: ${SUPAGO_DATABASE_URL}
generation:
output: internal/adapters/supago# .env
SUPAGO_DATABASE_URL=postgresql://postgres:password@localhost:5432/postgres| Command | Description |
|---|---|
init |
Initialize SupaGo in an existing Go project |
inspect |
Inspect the database schema and display tables, columns, types, and constraints |
generate model |
Generate Go structs from database tables |
generate repository |
Generate Go repositories with full CRUD per table |
generate crud |
Generate services and HTTP handlers using net/http as a starting point |
generate all |
Run the full generation pipeline (model, repository, crud) |
version |
Print the version of SupaGo |
MIT
