go-nunu / nunu

A CLI tool for building Go applications.
https://go-nunu.github.io/nunu/
MIT License
1.93k stars 141 forks source link
ddd gin go golang golang-cli scaffold

go-nunu%2Fnunu | Trendshift

Nunu โ€” A CLI tool for building Go applications.

Nunu is a scaffolding tool for building Go applications. Its name comes from a game character in League of Legends, a little boy riding on the shoulders of a Yeti. Just like Nunu, this project stands on the shoulders of giants, as it is built upon a combination of popular libraries from the Go ecosystem. This combination allows you to quickly build efficient and reliable applications.

๐Ÿš€Tips: This project is very complete, so updates will not be very frequent, welcome to use.

Nunu

Documentation

Features

Key Features

Concise Layered Architecture

Nunu adopts a classic layered architecture. In order to achieve modularity and decoupling, it uses the dependency injection framework Wire.

Nunu Layout

Nunu CLI

Nunu

Directory Structure

.
โ”œโ”€โ”€ api
โ”‚ย ย  โ””โ”€โ”€ v1
โ”œโ”€โ”€ cmd
โ”‚ย ย  โ”œโ”€โ”€ migration
โ”‚ย ย  โ”œโ”€โ”€ server
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ wire
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ wire.go
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ wire_gen.go
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ main.go
โ”‚ย ย  โ””โ”€โ”€ task
โ”œโ”€โ”€ config
โ”œโ”€โ”€ deploy
โ”œโ”€โ”€ docs
โ”œโ”€โ”€ internal
โ”‚ย ย  โ”œโ”€โ”€ handler
โ”‚ย ย  โ”œโ”€โ”€ middleware
โ”‚ย ย  โ”œโ”€โ”€ model
โ”‚ย ย  โ”œโ”€โ”€ repository
โ”‚ย ย  โ”œโ”€โ”€ server
โ”‚ย ย  โ””โ”€โ”€ service
โ”œโ”€โ”€ pkg
โ”œโ”€โ”€ scripts
โ”œโ”€โ”€ test
โ”‚ย ย  โ”œโ”€โ”€ mocks
โ”‚ย ย  โ””โ”€โ”€ server
โ”œโ”€โ”€ web
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ go.mod
โ””โ”€โ”€ go.sum

The project architecture follows a typical layered structure, consisting of the following modules:

In addition, there are some other files and directories, such as license files, build files, and README. Overall, the project architecture is clear, with clear responsibilities for each module, making it easy to understand and maintain.

Requirements

To use Nunu, you need to have the following software installed on your system:

Installation

You can install Nunu with the following command:

go install github.com/go-nunu/nunu@latest

Tips: If go install succeeds but the nunu command is not recognized, it is because the environment variable is not configured. You can add the GOBIN directory to the environment variable.

Create a New Project

You can create a new Go project with the following command:

nunu new projectName

By default, it pulls from the GitHub source, but you can also use an accelerated repository in China:

// Use the basic template
nunu new projectName -r https://gitee.com/go-nunu/nunu-layout-basic.git
// Use the advanced template
nunu new projectName -r https://gitee.com/go-nunu/nunu-layout-advanced.git

This command will create a directory named projectName and generate an elegant Go project structure within it.

Create Components

You can create handlers, services, repositories, and models for your project using the following commands:

nunu create handler user
nunu create service user
nunu create repository user
nunu create model user

or

nunu create all user

These commands will create components named UserHandler, UserService, UserRepository, and UserModel, respectively, and place them in the correct directories.

Run the Project

You can quickly run the project with the following command:

nunu run

This command will start your Go project and support hot-reloading when files are updated.

Compile wire.go

You can quickly compile wire.go with the following command:

nunu wire

This command will compile your wire.go file and generate the required dependencies.

Contribution

If you find any issues or have any improvement suggestions, please feel free to raise an issue or submit a pull request. Your contributions are highly appreciated!

License

Nunu is released under the MIT License. For more information, see the LICENSE file.

Star History

Star History Chart