go-boilerplate

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 5 Imported by: 0

README

go-boilerplate 🚀

Go Report Card License Go with Confidence

This boilerplate is intended to be used as a starting point for a go application. It is not intended to be used as a but it is can be.

Getting Started

Prerequisites
  • Go 1.20
  • Docker
Installation
  1. Clone the repo
    git clone https://github.com/kondohiroki/go-boilerplate.git
    
  2. Install Go dependencies
    go mod download
    
  3. Copy the default configuration file
    cp config/config.example.yaml config/config.yaml
    
  4. Start the database
    docker compose up -d
    
  5. Run the application
    # Run normally
    go run main.go serve-api
    
    # Run with hot reload
    air serve-api
    

How to Use

Configuration
  • config/config.yaml (ignored by git)
    • Default configuration file
  • cmd/root.go
    • config/config.yaml is loaded by default
    • You can specify the configuration file with the --config flag
  • internal/app/<your-handler>/<xxx>.go
    • Define your handler functions for your endpoint
  • internal/logger/zap_logger.go
    • You can see the log settings in the NewZapLogger function
  • job/
    • You can add your own jobs here
  • scheduler/scheduler.go
    • You can schedule your jobs here
    • You can configure the cron expression in config/config.yaml

Supported Features

  • Configuration with YAML
  • Logging with Zap Logger
  • CLI with Cobra
  • Scheduler with Cron
  • PostgreSQL
  • Redis Cache
  • Docker
  • Fiber Router

Use Cases

  • As a Web Server
    • HTTP API
    • gRPC API
  • As a CLI Application
  • As a Scheduler for Cron Jobs

Roadmap

  • Add gRPC API
  • Add Redis Reliable Queue
  • Document the code

License

Distributed under the MIT License. See LICENSE for more information.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL