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 adopts a classic layered architecture. In order to achieve modularity and decoupling, it uses the dependency injection framework Wire
.
.
โโโ 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:
cmd
: This module contains the entry points of the application, which perform different operations based on different commands, such as starting the server or executing database migrations. Each sub-module has a main.go
file as the entry file, as well as wire.go
and wire_gen.go
files for dependency injection.
config
: This module contains the configuration files for the application, providing different configurations for different environments, such as development and production.
deploy
: This module is used for deploying the application and includes deployment scripts and configuration files.
internal
: This module is the core module of the application and contains the implementation of various business logic.
handler
: This sub-module contains the handlers for handling HTTP requests, responsible for receiving requests and invoking the corresponding services for processing.
job
: This sub-module contains the logic for background tasks.
model
: This sub-module contains the definition of data models.
repository
: This sub-module contains the implementation of the data access layer, responsible for interacting with the database.
server
: This sub-module contains the implementation of the HTTP server.
service
: This sub-module contains the implementation of the business logic, responsible for handling specific business operations.
pkg
: This module contains some common utilities and functions.
scripts
: This module contains some script files used for project build, test, and deployment operations.
storage
: This module is used for storing files or other static resources.
test
: This module contains the unit tests for various modules, organized into sub-directories based on modules.
web
: This module contains the frontend-related files, such as HTML, CSS, and JavaScript.
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.
To use Nunu, you need to have the following software installed on your system:
You can install Nunu with the following command:
go install github.com/go-nunu/nunu@latest
Tips: If
go install
succeeds but thenunu
command is not recognized, it is because the environment variable is not configured. You can add the GOBIN directory to the environment variable.
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.
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.
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.
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.
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!
Nunu is released under the MIT License. For more information, see the LICENSE file.