feat: Supports Websocket/TCP

This commit is contained in:
chris
2024-05-11 10:45:49 +08:00
parent 9e880d452d
commit 037bf21781
10 changed files with 29 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Nunu
Copyright (c) 2023-2024 Nunu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -30,6 +30,7 @@ Nunu is a scaffolding tool for building Go applications. Its name comes from a g
- **Go-sqlmock**: https://github.com/DATA-DOG/go-sqlmock
- **Gomock**: https://github.com/golang/mock
- **Swaggo**: https://github.com/swaggo/swag
- **Pitaya**: https://github.com/topfreegames/pitaya
- More...
## Key Features

View File

@@ -30,6 +30,7 @@ Nunu é uma ferramenta de geração de estrutura (scaffolding) para construir ap
- **Go-sqlmock**: https://github.com/DATA-DOG/go-sqlmock
- **Gomock**: https://github.com/golang/mock
- **Swaggo**: https://github.com/swaggo/swag
- **Pitaya**: https://github.com/topfreegames/pitaya
- Mais...
## Funcionalidades Principais

View File

@@ -30,6 +30,7 @@ Nunu是一个基于Golang的应用脚手架它的名字来自于英雄联盟
- **Go-sqlmock**: https://github.com/DATA-DOG/go-sqlmock
- **Gomock**: https://github.com/golang/mock
- **Swaggo**: https://github.com/swaggo/swag
- **Pitaya**: https://github.com/topfreegames/pitaya
- More...
## 特性
* **超低学习成本和定制**Nunu封装了Gopher最熟悉的一些流行库。您可以轻松定制应用程序以满足特定需求。

View File

@@ -16,7 +16,7 @@ var CmdRoot = &cobra.Command{
Use: "nunu",
Example: "nunu new demo-api",
Short: "\n _ _ \n| \\ | |_ _ _ __ _ _ \n| \\| | | | | '_ \\| | | |\n| |\\ | |_| | | | | |_| |\n|_| \\_|\\__,_|_| |_|\\__,_| \n \n" + "\x1B[38;2;66;211;146mA\x1B[39m \x1B[38;2;67;209;149mC\x1B[39m\x1B[38;2;68;206;152mL\x1B[39m\x1B[38;2;69;204;155mI\x1B[39m \x1B[38;2;70;201;158mt\x1B[39m\x1B[38;2;71;199;162mo\x1B[39m\x1B[38;2;72;196;165mo\x1B[39m\x1B[38;2;73;194;168ml\x1B[39m \x1B[38;2;74;192;171mf\x1B[39m\x1B[38;2;75;189;174mo\x1B[39m\x1B[38;2;76;187;177mr\x1B[39m \x1B[38;2;77;184;180mb\x1B[39m\x1B[38;2;78;182;183mu\x1B[39m\x1B[38;2;79;179;186mi\x1B[39m\x1B[38;2;80;177;190ml\x1B[39m\x1B[38;2;81;175;193md\x1B[39m\x1B[38;2;82;172;196mi\x1B[39m\x1B[38;2;83;170;199mn\x1B[39m\x1B[38;2;83;167;202mg\x1B[39m \x1B[38;2;84;165;205mg\x1B[39m\x1B[38;2;85;162;208mo\x1B[39m \x1B[38;2;86;160;211ma\x1B[39m\x1B[38;2;87;158;215mp\x1B[39m\x1B[38;2;88;155;218ml\x1B[39m\x1B[38;2;89;153;221mi\x1B[39m\x1B[38;2;90;150;224mc\x1B[39m\x1B[38;2;91;148;227ma\x1B[39m\x1B[38;2;92;145;230mt\x1B[39m\x1B[38;2;93;143;233mi\x1B[39m\x1B[38;2;94;141;236mo\x1B[39m\x1B[38;2;95;138;239mn\x1B[39m\x1B[38;2;96;136;243m.\x1B[39m",
Version: fmt.Sprintf("\n _ _ \n| \\ | |_ _ _ __ _ _ \n| \\| | | | | '_ \\| | | |\n| |\\ | |_| | | | | |_| |\n|_| \\_|\\__,_|_| |_|\\__,_| \n \nNunu %s - Copyright (c) 2023 Nunu\nReleased under the MIT License.\n\n", config.Version),
Version: fmt.Sprintf("\n _ _ \n| \\ | |_ _ _ __ _ _ \n| \\| | | | | '_ \\| | | |\n| |\\ | |_| | | | | |_| |\n|_| \\_|\\__,_|_| |_|\\__,_| \n \nNunu %s - Copyright (c) 2023-2024 Nunu\nReleased under the MIT License.\n\n", config.Version),
}
func init() {

View File

@@ -1,11 +1,12 @@
package config
var (
Version = "1.0.16"
Version = "1.1.0"
WireCmd = "github.com/google/wire/cmd/wire@latest"
NunuCmd = "github.com/go-nunu/nunu@latest"
RepoBase = "https://github.com/go-nunu/nunu-layout-base.git"
RepoAdvanced = "https://github.com/go-nunu/nunu-layout-advanced.git"
RepoChat = "https://github.com/go-nunu/nunu-layout-chat.git"
RunExcludeDir = ".git,.idea,tmp,vendor"
RunIncludeExt = "go,html,yaml,yml,toml,ini,json,xml,tpl,tmpl"
)

View File

@@ -31,17 +31,8 @@ nunu new projectName
This command will create a directory named `projectName` and generate an elegant Golang project structure within it.
**Accelerated Source in China:**
By default, `nunu new` fetches from the GitHub source. However, you can also use an accelerated repository in China:
```
// Using the basic template
nunu new projectName -r https://gitee.com/go-nunu/nunu-layout-basic.git
// Using the advanced template (recommended)
nunu new projectName -r https://gitee.com/go-nunu/nunu-layout-advanced.git
```
> Nunu provides two types of layouts:
> Nunu provides 3 types of layouts:
* **Basic Layout**
@@ -53,6 +44,9 @@ The Basic Layout contains a minimalistic directory structure and is suitable for
The Advanced Layout includes many examples of using Nunu (e.g., db, redis, jwt, cron, migration, etc.), which is suitable for developers to quickly learn and understand the architectural ideas of Nunu.
* **Chat Layout**
Chat Layout is a Nunu based long link project template suitable for scenarios such as instant messaging and game development.
## Quick Start with Docker

View File

@@ -50,11 +50,14 @@ nunu new projectName -r https://gitee.com/go-nunu/nunu-layout-advanced.git
// 使用基础模板
nunu new projectName -r https://gitee.com/go-nunu/nunu-layout-basic.git
// 使用ws/tcp模板(适合即时通信、游戏开发等场景)
nunu new projectName -r https://gitee.com/go-nunu/nunu-layout-chat.git
```
> Nunu内置了种类型的Layout
> Nunu内置了种类型的Layout
* **基础模板(Basic Layout)**
@@ -67,6 +70,9 @@ Basic Layout 包含一个非常精简的架构目录结构适合非常熟悉N
Advanced Layout 包含了很多Nunu的用法示例 db、redis、 jwt、 cron、 migration等适合开发者快速学习了解Nunu的架构思想。
* **即时通信模板(Chat Layout)**
Chat Layout 是一个基于Nunu的长链接项目模板适合适合即时通信、游戏开发等场景。
## 使用docker快速启动项目

View File

@@ -111,11 +111,15 @@ func (p *Project) cloneTemplate() (bool, error) {
Options: []string{
"Advanced",
"Basic",
"Chat",
},
Description: func(value string, index int) string {
if index == 1 {
return "A basic project structure"
}
if index == 2 {
return "A simple chat room containing websocket/tcp"
}
return "It has rich functions such as db, jwt, cron, migration, test, etc"
},
}
@@ -123,8 +127,10 @@ func (p *Project) cloneTemplate() (bool, error) {
if err != nil {
return false, err
}
if layout != "Basic" {
if layout == "Advanced" {
repo = config.RepoAdvanced
} else if layout == "Chat" {
repo = config.RepoChat
}
err = os.RemoveAll(p.ProjectName)
if err != nil {

View File

@@ -9,8 +9,10 @@ import (
type {{ .StructName }}Service interface {
Get{{ .StructName }}(ctx context.Context, id int64) (*model.{{ .StructName }}, error)
}
func New{{ .StructName }}Service(service *Service, {{ .StructNameLowerFirst }}Repository repository.{{ .StructName }}Repository) {{ .StructName }}Service {
func New{{ .StructName }}Service(
service *Service,
{{ .StructNameLowerFirst }}Repository repository.{{ .StructName }}Repository,
) {{ .StructName }}Service {
return &{{ .StructNameLowerFirst }}Service{
Service: service,
{{ .StructNameLowerFirst }}Repository: {{ .StructNameLowerFirst }}Repository,