Thanks to visit codestin.com
Credit goes to github.com

Skip to content

go-sweets/sweets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-sweets

English | 简体中文

⚠️ Repository Reorganized: This repository has been reorganized. All code has been moved to the main repository.

New Repository: go-sweets/go-sweets


Overview

go-sweets is a Go framework for building cloud-native microservices with modern tools and best practices. It provides:

  • CLI Tool: Project scaffolding tool
  • Service Template: Production-ready microservice implementation using CloudWeGo framework
  • Shared Packages: Reusable utilities for common tasks

Quick Start

1. Install CLI Tool

git clone https://github.com/go-sweets/go-sweets.git
cd go-sweets/cli
go build -o mpctl main.go

2. Generate a New Service

./mpctl new <service-name>

3. Run Your Service

The generated service includes everything you need:

cd <service-name>
go mod tidy
make run

By default, the service listens on:

  • HTTP: http://localhost:8080 (Hertz)
  • RPC: localhost:9090 (Kitex)

4. Test Your Service

curl 'http://localhost:8080/v1/hello?id=1'

Expected response:

{"id":"1","message":"Hello 1 !"}

Architecture

Service Template (sweets-layout)

Complete microservice implementation featuring:

  • CloudWeGo Hertz: High-performance HTTP framework
  • CloudWeGo Kitex: High-performance RPC framework with Protocol Buffers
  • Wire: Compile-time dependency injection
  • GORM: Database ORM with Goose migrations
  • Redis: Caching and session management
  • DDD Architecture: Domain-Driven Design with bounded contexts

See sweets-layout/CLAUDE.md for detailed documentation.

Shared Packages (common/)

Independent utility packages:

  • conf/: Configuration management
  • di/: Dependency injection utilities
  • validator/: Input validation
  • hash/: Hashing utilities
  • lock/: Distributed locking
  • migrate/: Database migration tools
  • resp/: Response formatting
  • contains/: Container utilities
  • convert/: Type conversion utilities
  • errcode/: Error code management
  • str/: String utilities
  • plugins/gorm/filter/: GORM database filters

Development

Building the CLI

cd cli
go build -o mpctl main.go

Working with Service Template

cd sweets-layout
make init     # Install dependencies and tools
make proto    # Generate protobuf code
make wire     # Run Wire dependency injection
make run      # Run the service
make test     # Run tests
make lint     # Run linter

Using Shared Packages

Import packages in your code:

import "github.com/go-sweets/go-sweets/common/<package-name>"

Or use local replace directives during development:

replace github.com/go-sweets/go-sweets/common/conf => ../common/conf

Documentation

License

Apache License Version 2.0 - See LICENSE for details.

Contributing

Contributions are welcome! Please visit the main repository to contribute.

About

A cloud-native Go microservices framework with cli tool for productivity.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •