Skip to content

Commit

Permalink
feat: Supports Websocket/TCP
Browse files Browse the repository at this point in the history
  • Loading branch information
codingcn committed May 11, 2024
1 parent 9e880d4 commit 037bf21
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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最熟悉的一些流行库。您可以轻松定制应用程序以满足特定需求。
Expand Down
2 changes: 1 addition & 1 deletion cmd/nunu/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -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"
)
14 changes: 4 additions & 10 deletions docs/en/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand All @@ -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

Expand Down
8 changes: 7 additions & 1 deletion docs/zh/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)**

Expand All @@ -67,6 +70,9 @@ Basic Layout 包含一个非常精简的架构目录结构,适合非常熟悉N

Advanced Layout 包含了很多Nunu的用法示例( db、redis、 jwt、 cron、 migration等),适合开发者快速学习了解Nunu的架构思想。

* **即时通信模板(Chat Layout)**

Chat Layout 是一个基于Nunu的长链接项目模板,适合适合即时通信、游戏开发等场景。


## 使用docker快速启动项目
Expand Down
8 changes: 7 additions & 1 deletion internal/command/new/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,26 @@ 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"
},
}
err := survey.AskOne(prompt, &layout)
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 {
Expand Down
6 changes: 4 additions & 2 deletions tpl/create/service.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 037bf21

Please sign in to comment.