Compare commits
2 Commits
v1.3.0
...
tools/goct
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f46eab977 | ||
|
|
ec299085f5 |
@@ -54,7 +54,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/tal-tech/go-zero/core/mr"
|
"github.com/zeromicro/go-zero/core/mr"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/tal-tech/go-zero/core/mr"
|
"github.com/zeromicro/go-zero/core/mr"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -87,4 +87,4 @@ More examples: [https://github.com/zeromicro/zero-examples/tree/main/mapreduce](
|
|||||||
|
|
||||||
## Give a Star! ⭐
|
## Give a Star! ⭐
|
||||||
|
|
||||||
If you like or are using this project to learn or start your solution, please give it a star. Thanks!
|
If you like or are using this project to learn or start your solution, please give it a star. Thanks!
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ go-zero 是一个集成了各种工程实践的包含 web 和 rpc 框架,有
|
|||||||
在项目目录下通过如下命令安装:
|
在项目目录下通过如下命令安装:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero
|
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero
|
||||||
```
|
```
|
||||||
|
|
||||||
## 5. Quick Start
|
## 5. Quick Start
|
||||||
@@ -106,10 +106,10 @@ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Go 1.15 及之前版本
|
# Go 1.15 及之前版本
|
||||||
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl@latest
|
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl@latest
|
||||||
|
|
||||||
# Go 1.16 及以后版本
|
# Go 1.16 及以后版本
|
||||||
GOPROXY=https://goproxy.cn/,direct go install github.com/tal-tech/go-zero/tools/goctl@latest
|
GOPROXY=https://goproxy.cn/,direct go install github.com/zeromicro/go-zero/tools/goctl@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
确保 goctl 可执行
|
确保 goctl 可执行
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ As below, go-zero protects the system with a couple of layers and mechanisms:
|
|||||||
Run the following command under your project:
|
Run the following command under your project:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
go get -u github.com/tal-tech/go-zero
|
go get -u github.com/zeromicro/go-zero
|
||||||
```
|
```
|
||||||
|
|
||||||
## 6. Quick Start
|
## 6. Quick Start
|
||||||
@@ -107,10 +107,10 @@ go get -u github.com/tal-tech/go-zero
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
# for Go 1.15 and earlier
|
# for Go 1.15 and earlier
|
||||||
GO111MODULE=on go get -u github.com/tal-tech/go-zero/tools/goctl@latest
|
GO111MODULE=on go get -u github.com/zeromicro/go-zero/tools/goctl@latest
|
||||||
|
|
||||||
# for Go 1.16 and later
|
# for Go 1.16 and later
|
||||||
go install github.com/tal-tech/go-zero/tools/goctl@latest
|
go install github.com/zeromicro/go-zero/tools/goctl@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
make sure goctl is executable.
|
make sure goctl is executable.
|
||||||
|
|||||||
7
tools/goctl/migrate/cancel+polyfill.go
Normal file
7
tools/goctl/migrate/cancel+polyfill.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
//go:build windows
|
||||||
|
// +build windows
|
||||||
|
|
||||||
|
package migrate
|
||||||
|
|
||||||
|
func cancelOnSignals() {
|
||||||
|
}
|
||||||
31
tools/goctl/migrate/cancel.go
Normal file
31
tools/goctl/migrate/cancel.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
//go:build linux || darwin
|
||||||
|
// +build linux darwin
|
||||||
|
|
||||||
|
package migrate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/syncx"
|
||||||
|
"github.com/zeromicro/go-zero/tools/goctl/util/console"
|
||||||
|
)
|
||||||
|
|
||||||
|
func cancelOnSignals() {
|
||||||
|
doneChan := syncx.NewDoneChan()
|
||||||
|
defer doneChan.Close()
|
||||||
|
|
||||||
|
go func(dc *syncx.DoneChan) {
|
||||||
|
c := make(chan os.Signal)
|
||||||
|
signal.Notify(c, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGINT, syscall.SIGTSTP, syscall.SIGQUIT)
|
||||||
|
select {
|
||||||
|
case <-c:
|
||||||
|
console.Error(`
|
||||||
|
migrate failed, reason: "User Canceled"`)
|
||||||
|
os.Exit(0)
|
||||||
|
case <-dc.Done():
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}(doneChan)
|
||||||
|
}
|
||||||
@@ -10,16 +10,13 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"github.com/zeromicro/go-zero/core/syncx"
|
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/console"
|
"github.com/zeromicro/go-zero/tools/goctl/util/console"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/ctx"
|
"github.com/zeromicro/go-zero/tools/goctl/util/ctx"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/vars"
|
"github.com/zeromicro/go-zero/tools/goctl/vars"
|
||||||
@@ -71,22 +68,7 @@ func rewriteImport(verbose bool) error {
|
|||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
doneChan := syncx.NewDoneChan()
|
cancelOnSignals()
|
||||||
defer func() {
|
|
||||||
doneChan.Close()
|
|
||||||
}()
|
|
||||||
go func(dc *syncx.DoneChan) {
|
|
||||||
c := make(chan os.Signal)
|
|
||||||
signal.Notify(c, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGINT, syscall.SIGTSTP, syscall.SIGQUIT)
|
|
||||||
select {
|
|
||||||
case <-c:
|
|
||||||
console.Error(`
|
|
||||||
migrate failed, reason: "User Canceled"`)
|
|
||||||
os.Exit(0)
|
|
||||||
case <-dc.Done():
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}(doneChan)
|
|
||||||
|
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const deprecatedGoZeroMod = "github.com/tal-tech/go-zero"
|
const deprecatedGoZeroMod = "github.com/tal-tech/go-zero"
|
||||||
|
|
||||||
const deprecatedBuilderx = "github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx"
|
const deprecatedBuilderx = "github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx"
|
||||||
const replacementBuilderx = "github.com/zeromicro/go-zero/core/stores/builder"
|
const replacementBuilderx = "github.com/zeromicro/go-zero/core/stores/builder"
|
||||||
const goZeroMod = "github.com/zeromicro/go-zero"
|
const goZeroMod = "github.com/zeromicro/go-zero"
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ type User struct {
|
|||||||
|
|
||||||
"github.com/globalsign/mgo/bson"
|
"github.com/globalsign/mgo/bson"
|
||||||
cachec "github.com/zeromicro/go-zero/core/stores/cache"
|
cachec "github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
"github.com/tal-tech/go-zero/core/stores/mongoc"
|
"github.com/zeromicro/go-zero/core/stores/mongoc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserModel interface {
|
type UserModel interface {
|
||||||
@@ -207,4 +207,4 @@ OPTIONS:
|
|||||||
|
|
||||||
types.go本质上与xxxmodel.go无关,只是将type定义部分交给开发人员自己编写了,在xxxmodel.go中,mongo文档的存储结构必须包含
|
types.go本质上与xxxmodel.go无关,只是将type定义部分交给开发人员自己编写了,在xxxmodel.go中,mongo文档的存储结构必须包含
|
||||||
`_id`字段,对应到types中的field为`ID`,model中的findOne,update均以data.ID来进行操作的,当然,如果不符合你的命名风格,你也 可以修改模板,只要保证`id`
|
`_id`字段,对应到types中的field为`ID`,model中的findOne,update均以data.ID来进行操作的,当然,如果不符合你的命名风格,你也 可以修改模板,只要保证`id`
|
||||||
在types中的field名称和模板中一致就行。
|
在types中的field名称和模板中一致就行。
|
||||||
|
|||||||
Reference in New Issue
Block a user