{"id":31390922,"url":"https://github.com/nkaewam/taskw","last_synced_at":"2025-09-29T01:53:47.183Z","repository":{"id":311499710,"uuid":"1043869427","full_name":"nkaewam/taskw","owner":"nkaewam","description":"Go route generation + dependency injection framework based on Fiber + Wire + Swag + Taskfile","archived":false,"fork":false,"pushed_at":"2025-09-13T14:25:19.000Z","size":523,"stargazers_count":22,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-13T16:27:01.235Z","etag":null,"topics":["codegen","dependency-injection","fiber","golang","wire"],"latest_commit_sha":null,"homepage":"https://taskw.nkaewam.dev","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nkaewam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-24T19:37:34.000Z","updated_at":"2025-09-13T14:25:23.000Z","dependencies_parsed_at":"2025-08-24T23:50:13.002Z","dependency_job_id":"f1f6b44d-2149-473d-9555-93069e6316e8","html_url":"https://github.com/nkaewam/taskw","commit_stats":null,"previous_names":["nkaewam/taskw"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/nkaewam/taskw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkaewam%2Ftaskw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkaewam%2Ftaskw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkaewam%2Ftaskw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkaewam%2Ftaskw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nkaewam","download_url":"https://codeload.github.com/nkaewam/taskw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkaewam%2Ftaskw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277455235,"owners_count":25820680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codegen","dependency-injection","fiber","golang","wire"],"created_at":"2025-09-29T01:53:42.752Z","updated_at":"2025-09-29T01:53:47.174Z","avatar_url":"https://github.com/nkaewam.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Taskw - Go API Code Generator\n\n![Taskw](./docs/taskw-thumb.png)\n\nA CLI tool for automatically generating Fiber routes and Wire dependency injection code from annotations. Taskw eliminates boilerplate and keeps your API handlers focused on business logic.\n\n## What Problem Does Taskw Solve?\n\nWhen building Go APIs, you typically write:\n\n1. **Handler functions** with route annotations based on [Swaggo](https://github.com/swaggo/swag) (`@Router /api/users [get]`)\n2. **Provider functions** for dependency injection (`func Provide\u003cFUNCTION_NAME\u003e()`)\n3. **Boilerplate route registration** (manually wiring routes to handlers)\n4. **Boilerplate dependency wiring** (manually connecting all providers)\n\nTaskw automatically generates #3 and #4 by scanning your code for annotations and provider functions.\n\n## Features (v1)\n\n**🎯 Focused Stack:**\n\n- **Web Framework**: Fiber v2 only\n- **Dependency Injection**: Google Wire only\n- **Annotations**: Swaggo (@Router) only\n- **Language**: Go\n\n**🚀 What It Generates:**\n\n- Auto-route registration from `@Router` annotations\n- Wire provider sets from `Provide*` functions\n- Type-safe dependency injection code\n- Development-friendly watching and regeneration\n\n## Installation\n\n### Option 1: Install from source (Recommended)\n\n```bash\ngo install github.com/nkaewam/taskw@latest\n```\n\n### Option 2: Download pre-built binaries\n\nDownload the latest binary for your platform from the [releases page](https://github.com/nkaewam/taskw/releases).\n\n### Option 3: Build from source\n\n```bash\ngit clone https://github.com/nkaewam/taskw.git\ncd taskw\ngo build -o taskw main.go\nsudo mv taskw /usr/local/bin/\n```\n\n## Quick Start\n\n### 1. Initialize in your project\n\n```bash\ntaskw init\n```\n\nThis creates a `taskw.yaml` config file:\n\n```yaml\nversion: \"1.0\"\nproject:\n  module: \"github.com/user/your-go-api\"\npaths:\n  scan_dirs:\n    - \"./internal/api\"\n    - \"./internal/handlers\"\n  output_dir: \"./internal/api\"\ngeneration:\n  routes:\n    enabled: true\n    output_file: \"routes_gen.go\"\n  dependencies:\n    enabled: true\n    output_file: \"dependencies_gen.go\"\n```\n\n### 2. Write handlers with annotations\n\n```go\n// internal/api/user/handler.go\npackage user\n\nimport \"github.com/gofiber/fiber/v2\"\n\ntype Handler struct {\n    service *Service\n}\n\n// ProvideHandler creates a new user handler\nfunc ProvideHandler(service *Service) *Handler {\n    return \u0026Handler{service: service}\n}\n\n// GetUsers retrieves all users\n// @Summary Get all users\n// @Description Get a list of all users\n// @Tags users\n// @Accept json\n// @Produce json\n// @Success 200 {array} User\n// @Router /api/v1/users [get]\nfunc (h *Handler) GetUsers(c *fiber.Ctx) error {\n    users, err := h.service.GetAll()\n    if err != nil {\n        return c.Status(500).JSON(fiber.Map{\"error\": err.Error()})\n    }\n    return c.JSON(users)\n}\n\n// CreateUser creates a new user\n// @Summary Create user\n// @Description Create a new user\n// @Tags users\n// @Accept json\n// @Produce json\n// @Param user body CreateUserRequest true \"User data\"\n// @Success 201 {object} User\n// @Router /api/v1/users [post]\nfunc (h *Handler) CreateUser(c *fiber.Ctx) error {\n    // Implementation here\n    return c.SendStatus(201)\n}\n```\n\n### 3. Write services with providers\n\n```go\n// internal/api/user/service.go\npackage user\n\ntype Service struct {\n    repo Repository\n}\n\n// ProvideService creates a new user service\nfunc ProvideService(repo Repository) *Service {\n    return \u0026Service{repo: repo}\n}\n\nfunc (s *Service) GetAll() ([]User, error) {\n    return s.repo.FindAll()\n}\n```\n\n### 4. Generate code\n\n```bash\ntaskw generate\n```\n\nThis generates:\n\n- `internal/api/routes_gen.go` - Auto-route registration\n- `internal/api/dependencies_gen.go` - Wire provider sets\n\n### 5. Use generated code\n\n```go\n// cmd/server/main.go\npackage main\n\nimport (\n    \"github.com/gofiber/fiber/v2\"\n    \"your-module/internal/api\"\n)\n\nfunc main() {\n    app := fiber.New()\n\n    // Wire generates this function\n    server, cleanup, err := api.InitializeServer()\n    if err != nil {\n        panic(err)\n    }\n    defer cleanup()\n\n    // Auto-generated route registration\n    if err := server.RegisterRoutes(app); err != nil {\n        panic(err)\n    }\n\n    app.Listen(\":8080\")\n}\n```\n\n## Commands\n\n```bash\n# Initialize taskw in existing project\ntaskw init\n\n# Generate all code\ntaskw generate\n\n# Generate specific components\ntaskw generate routes      # Only route registration\ntaskw generate deps        # Only dependency injection\n\n# Watch for changes during development\ntaskw watch\n\n# Debug what Taskw finds\ntaskw scan                 # Show discovered handlers and providers\n```\n\n## Configuration Reference\n\n```yaml\n# taskw.yaml\nversion: \"1.0\"\n\n# Project information\nproject:\n  module: \"github.com/user/my-api\" # Go module from go.mod\n\n# File paths\npaths:\n  scan_dirs: # Directories to scan\n    - \"./internal/api\"\n    - \"./internal/handlers\"\n    - \"./pkg/handlers\"\n  output_dir: \"./internal/api\" # Where to write generated files\n\n# Code generation settings\ngeneration:\n  routes:\n    enabled: true\n    output_file: \"routes_gen.go\" # Generated route registration\n  dependencies:\n    enabled: true\n    output_file: \"deps_gen.go\" # Generated Wire providers\n```\n\n## How It Works\n\n### Route Generation\n\nTaskw scans for:\n\n1. **@Router annotations** in comments above handler methods\n2. **Provide\\* functions** that return handler types\n\nGenerated code:\n\n```go\n// routes_gen.go (generated)\nfunc (s *Server) RegisterRoutes(app *fiber.App) {\n    app.Get(\"/api/v1/users\", s.userHandler.GetUsers)\n    app.Post(\"/api/v1/users\", s.userHandler.CreateUser)\n    // ... more routes\n}\n```\n\n### Dependency Generation\n\nTaskw scans for:\n\n1. **Provider functions** starting with `Provide*`\n2. **Return types** and parameter dependencies\n\nGenerated code:\n\n```go\n// deps_gen.go (generated)\nvar ProviderSet = wire.NewSet(\n    user.ProvideHandler,\n    user.ProvideService,\n    user.ProvideRepository,\n    // ... more providers\n)\n```\n\n## Integration with Build Tools\n\n### Taskfile.yml\n\n```yaml\nversion: \"3\"\n\ntasks:\n  generate:\n    desc: Generate all code\n    cmds:\n      - taskw generate\n      - go generate ./...\n\n  dev:\n    desc: Start development server\n    deps: [generate]\n    cmds:\n      - air\n\n  build:\n    desc: Build application\n    deps: [generate]\n    cmds:\n      - go build -o bin/server cmd/server/main.go\n```\n\n### Makefile\n\n```makefile\n.PHONY: generate dev build\n\ngenerate:\n\ttaskw generate\n\tgo generate ./...\n\ndev: generate\n\tair\n\nbuild: generate\n\tgo build -o bin/server cmd/server/main.go\n```\n\n### Pre-commit Hook\n\n```bash\n#!/bin/sh\n# .git/hooks/pre-commit\ntaskw generate\ngit add internal/api/*_gen.go\n```\n\n## Examples\n\n### Complete Project Structure\n\n```\nmy-api/\n├── cmd/\n│   └── server/\n│       └── main.go\n├── internal/\n│   ├── api/\n│   │   ├── server.go\n│   │   ├── wire.go              # Manual Wire config\n│   │   ├── routes_gen.go        # Generated by Taskw\n│   │   ├── deps_gen.go          # Generated by Taskw\n│   │   └── wire_gen.go          # Generated by Wire\n│   ├── user/\n│   │   ├── handler.go           # Has @Router + ProvideHandler\n│   │   ├── service.go           # Has ProvideService\n│   │   └── repository.go        # Has ProvideRepository\n│   └── product/\n│       ├── handler.go\n│       ├── service.go\n│       └── repository.go\n├── taskw.yaml                   # Taskw config\n├── Taskfile.yml                 # Build config\n└── go.mod\n```\n\n### Wire Integration\n\n```go\n// internal/api/wire.go\n//go:build wireinject\n\npackage api\n\nimport (\n    \"github.com/google/wire\"\n    \"github.com/gofiber/fiber/v2\"\n    \"go.uber.org/zap\"\n)\n\n// ProviderSet combines manual + generated providers\nvar ProviderSet = wire.NewSet(\n    // Manual providers\n    provideLogger,\n    provideFiberApp,\n    // Generated providers (from deps_gen.go)\n    GeneratedProviderSet,\n    // Server\n    NewServer,\n)\n\nfunc InitializeServer() (*Server, func(), error) {\n    wire.Build(ProviderSet)\n    return \u0026Server{}, nil, nil\n}\n\nfunc provideLogger() *zap.Logger {\n    logger, _ := zap.NewProduction()\n    return logger\n}\n\nfunc provideFiberApp() *fiber.App {\n    return fiber.New()\n}\n```\n\n## Migration from Existing Projects\n\nIf you already have manual route/DI code:\n\n### 1. Install and initialize\n\n```bash\ntaskw init\n```\n\n### 2. Add @Router annotations to existing handlers\n\n```go\n// Before\nfunc (h *UserHandler) GetUsers(c *fiber.Ctx) error { ... }\n\n// After\n// @Router /api/v1/users [get]\nfunc (h *UserHandler) GetUsers(c *fiber.Ctx) error { ... }\n```\n\n### 3. Add Provide\\* functions\n\n```go\n// Add to existing files\nfunc ProvideUserHandler(service *UserService) *UserHandler {\n    return \u0026UserHandler{service: service}\n}\n```\n\n### 4. Generate and replace manual code\n\n```bash\ntaskw generate\n# Replace manual route registration with generated version\n# Replace manual Wire providers with generated version\n```\n\n## Development\n\n### Watch Mode\n\n```bash\n# Regenerate on file changes\ntaskw watch\n\n# Combine with Air for live reload\nair \u0026\ntaskw watch \u0026\n```\n\n### Debugging\n\n```bash\n# See what Taskw discovers\ntaskw scan\n\n# Output:\n# 📁 Scanning ./internal/api\n# 🔍 Found handlers:\n#   - user.ProvideHandler -\u003e *user.Handler\n#   - product.ProvideHandler -\u003e *product.Handler\n# 🔍 Found routes:\n#   - GetUsers: GET /api/v1/users\n#   - CreateUser: POST /api/v1/users\n# 📁 Scanning ./internal/handlers\n#   (no handlers found)\n```\n\n## Troubleshooting\n\n### Common Issues\n\n**Taskw doesn't find my handlers**\n\n- Check `scan_dirs` in `taskw.yaml`\n- Ensure files end with `handler.go`\n- Ensure functions start with `Provide*`\n\n**Generated routes don't work**\n\n- Check @Router annotation syntax\n- Ensure handler methods match `func (h *Handler) Method(c *fiber.Ctx) error`\n\n**Wire compilation fails**\n\n- Check provider function signatures\n- Ensure all dependencies have providers\n- Run `go generate ./...` after `taskw generate`\n\n**Generated code has wrong imports**\n\n- Check `project.module` in `taskw.yaml` matches `go.mod`\n\n### Debug Output\n\n```bash\n# Verbose mode\ntaskw generate --verbose\n\n# Show generated file contents\ntaskw generate --dry-run\n```\n\n## Roadmap\n\n**v1.1**\n\n- Watch mode (`taskw watch`)\n- Template customization\n- Better error messages\n\n**v2.0**\n\n- Support for Gin framework\n- Support for Fx dependency injection\n- Plugin system\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for new functionality\n4. Submit a pull request\n\n## License\n\nMIT License - see LICENSE file for details.\n\n---\n\n**Taskw** - From manual boilerplate to auto-generated bliss 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnkaewam%2Ftaskw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnkaewam%2Ftaskw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnkaewam%2Ftaskw/lists"}