update tal-tech to zeromicro

This commit is contained in:
kevin 2022-02-01 20:25:44 +08:00
parent 0779bd4b68
commit 767f1c4f00
97 changed files with 315 additions and 328 deletions

View File

@ -71,7 +71,7 @@ And now, lets walk through the complete flow of quickly create a microservice
* install goctl
```shell
GO111MODULE=on go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on go get -u github.com/zeromicro/go-zero/tools/goctl
```
* create the working dir `shorturl` and `shorturl/api`

View File

@ -77,7 +77,7 @@
* 安装 goctl 工具
```shell
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
```
* 创建工作目录 `shorturl``shorturl/api`
@ -94,7 +94,7 @@
require (
github.com/golang/mock v1.4.3
github.com/golang/protobuf v1.4.2
github.com/tal-tech/go-zero v1.1.4
github.com/zeromicro/go-zero v1.3.0
golang.org/x/net v0.0.0-20200707034311-ab3426394381
google.golang.org/grpc v1.29.1
)
@ -519,13 +519,13 @@
至此代码修改完成,凡是手动修改的代码我加了标注
**注意:**
1. undefined cache你需要 `import "github.com/tal-tech/go-zero/core/stores/cache"`
1. undefined cache你需要 `import "github.com/zeromicro/go-zero/core/stores/cache"`
2. undefined model, sqlx, hash 等,你需要在文件中
```golang
import "shorturl/rpc/transform/model"
import "github.com/tal-tech/go-zero/core/stores/sqlx"
import "github.com/zeromicro/go-zero/core/stores/sqlx"
```
## 10. 完整调用演示

View File

@ -19,7 +19,7 @@ footer: MIT Licensed | Copyright © 2020-present GoZero
---
```go
// 安装 go-zero
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
// 然后就可以开始你的微服务之旅了
```

View File

@ -13,9 +13,9 @@ import (
"flag"
"net/http"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/example/graceful/etcd/api/config"
"github.com/tal-tech/go-zero/rest"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/example/graceful/etcd/api/config"
"github.com/zeromicro/go-zero/rest"
)
var configFile = flag.String("f", "etc/graceful-api.json", "the config file")

View File

@ -66,7 +66,7 @@
* 安装goctl工具
```shell
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
```
* 创建工作目录 `bookstore``bookstore/api`

View File

@ -112,9 +112,6 @@ service user-api {
```
api 语法详细描述 [https://www.yuque.com/tal-tech/go-zero/ze9i30](https://www.yuque.com/tal-tech/go-zero/ze9i30)
总结如下:
1. info部分描述了api基本信息比如Authapi是哪个用途。

View File

@ -6,10 +6,10 @@
goctl是[go-zero](https://github.com/zeromico/go-zero)微服务框架下的代码生成工具其可以快速提升开发效率让开发人员将时间重点放在业务coding上其具体功能如下
- [api服务生成](https://www.yuque.com/tal-tech/go-zero/ppnpng)
- [rpc服务生成](https://www.yuque.com/tal-tech/go-zero/hlxlbt)
- [model代码生成](https://www.yuque.com/tal-tech/go-zero/nkg20f)
- [模板管理](https://www.yuque.com/tal-tech/go-zero/mkpuit)
- [api服务生成](https://www.yuque.com/zeromicro/go-zero/ppnpng)
- [rpc服务生成](https://www.yuque.com/zeromicro/go-zero/hlxlbt)
- [model代码生成](https://www.yuque.com/zeromicro/go-zero/nkg20f)
- [模板管理](https://www.yuque.com/zeromicro/go-zero/mkpuit)
@ -56,7 +56,7 @@ goctl version xxxxxx darwin/amd64
```bash
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl@latest
```
@ -66,7 +66,7 @@ $ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tec
### 方式二 fork and build
从[go-zero](https://github.com/zeromicro/go-zero)拉取一份go-zero源码`git@github.com:tal-tech/go-zero.git`进入goctl`tools/goctl/`目录下编译一下goctl文件然后将其添加到环境变量中。
从[go-zero](https://github.com/zeromicro/go-zero)拉取一份go-zero源码`git@github.com:zeromicro/go-zero.git`进入goctl`tools/goctl/`目录下编译一下goctl文件然后将其添加到环境变量中。
# 校验

View File

@ -25,7 +25,7 @@ package main
import (
"fmt"
"github.com/tal-tech/go-zero/tools/goctl/plugin"
"github.com/zeromicro/go-zero/tools/goctl/plugin"
)
func main() {

View File

@ -18,7 +18,7 @@ internal api的调用即通过内网直接访问api协议的方式获取数据
# rpc服务创建
首先创建library、user两个rpc服务这里就不详细描述rpc创建服务了rpc快速开始请点击[通过goctl快速创建rpc服务](https://www.yuque.com/tal-tech/go-zero/apuyly)
首先创建library、user两个rpc服务这里就不详细描述rpc创建服务了rpc快速开始请点击[通过goctl快速创建rpc服务](https://www.yuque.com/zeromicro/go-zero/apuyly)
这里我就直接把图书管理系统(library)和借阅系统(borrow)相关rpc服务代码上传到[github](https://github.com/anqiansong/book)中去了可以把course模块的代码直接拿过来使用,其中使用到的table数据表`library`的ddl如下:
@ -303,8 +303,8 @@ import (
"book/library/rpc/libraryclient"
"book/user/rpc/user"
"github.com/tal-tech/go-zero/core/stores/sqlx"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/zrpc"
)
type ServiceContext struct {

View File

@ -52,7 +52,7 @@ func NewMysqlModel(conn sqlx.SqlConn, table string) *MysqlModel {
准备一个 `User model` 
```go
var userBuilderQueryRows = strings.Join(builderx.FieldNames(&User{}), ",")
var userBuilderQueryRows = strings.Join(builder.FieldNames(&User{}), ",")
type User struct {
Avatar string `db:"avatar"` // 头像

View File

@ -277,7 +277,6 @@ func (tw *TimingWheel) getPositionAndCircle(d time.Duration) (pos int, circle in
## 参考资料
- [go-zero](https://github.com/zeromicro/go-zero)
- [go-zero 文档](https://www.yuque.com/tal-tech/go-zero)
- [go-zero中 collection.Cache](https://github.com/zeromicro/zero-doc/blob/main/doc/collection.md)
<Vssue title="timingWheel" />

View File

@ -182,10 +182,4 @@ $ curl -i -X POST http://localhost:8888/user/ping
本节主要演示怎样从创建api文件到启动一个api服务下一节我们将演示怎么连接访问数据库进行数据交互
# 参考文档
- [附录1:api语法定义](https://www.yuque.com/tal-tech/go-zero/ze9i30)
- [附录2:api目录结构](https://www.yuque.com/tal-tech/go-zero/wixzpx)
<Vssue title="创建API服务" />

View File

@ -7,8 +7,8 @@
package config
import (
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {

View File

@ -4,8 +4,5 @@
- [book示例源码](https://github.com/anqiansong/book)
- [rpc快速开始](https://www.yuque.com/tal-tech/go-zero/apuyly)
- [api语法](https://www.yuque.com/tal-tech/go-zero/ze9i30)
- [api目录结构](https://www.yuque.com/tal-tech/go-zero/wixzpx)
<Vssue title="附录3" />

View File

@ -1,12 +1,12 @@
<img align="right" width="150px" src="https://gitee.com/kevwan/static/raw/master/doc/images/go-zero.png">
# go-zero ![GitHub Repo stars](https://img.shields.io/github/stars/tal-tech/go-zero?style=social) ![GitHub forks](https://img.shields.io/github/forks/tal-tech/go-zero?style=social)
# go-zero ![GitHub Repo stars](https://img.shields.io/github/stars/zeromicro/go-zero?style=social) ![GitHub forks](https://img.shields.io/github/forks/zeromicro/go-zero?style=social)
[![Go](https://github.com/zeromicro/go-zero/workflows/Go/badge.svg?branch=master)](https://github.com/zeromicro/go-zero/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/tal-tech/go-zero)](https://goreportcard.com/report/github.com/tal-tech/go-zero)
[![Go Report Card](https://goreportcard.com/badge/github.com/zeromicro/go-zero)](https://goreportcard.com/report/github.com/zeromicro/go-zero)
[![goproxy](https://goproxy.cn/stats/github.com/tal-tech/go-zero/badges/download-count.svg)](https://goproxy.cn/stats/github.com/tal-tech/go-zero/badges/download-count.svg)
[![codecov](https://codecov.io/gh/zeromicro/go-zero/branch/master/graph/badge.svg)](https://codecov.io/gh/zeromicro/go-zero)
[![Release](https://img.shields.io/github/v/release/tal-tech/go-zero.svg?style=flat-square)](https://github.com/zeromicro/go-zero)
[![Release](https://img.shields.io/github/v/release/zeromicro/go-zero.svg?style=flat-square)](https://github.com/zeromicro/go-zero)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
## go-zero 简介
@ -87,16 +87,16 @@ go-zero 是一个集成了各种工程实践的包含 web 和 rpc 框架,有
在项目目录下通过如下命令安装:
```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
0. 完整示例请查看
[快速构建高并发微服务](https://github.com/tal-tech/zero-doc/blob/main/doc/shorturl.md)
[快速构建高并发微服务](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl.md)
[快速构建高并发微服务 - 多 RPC 版](https://github.com/tal-tech/zero-doc/blob/main/docs/zero/bookstore.md)
[快速构建高并发微服务 - 多 RPC 版](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/bookstore.md)
1. 安装 goctl 工具
@ -104,13 +104,13 @@ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/
来解放我们的双手👈
```shell
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
如果使用 go1.16 版本, 可以使用 `go install` 命令安装
```shell
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 可执行
@ -169,8 +169,8 @@ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/
* [goctl 使用帮助](goctl.md)
* awesome 系列(更多文章见『微服务实践』公众号)
* [快速构建高并发微服务](https://github.com/tal-tech/zero-doc/blob/main/doc/shorturl.md)
* [快速构建高并发微服务 - 多 RPC 版](https://github.com/tal-tech/zero-doc/blob/main/docs/zero/bookstore.md)
* [快速构建高并发微服务](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl.md)
* [快速构建高并发微服务 - 多 RPC 版](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/bookstore.md)
* 精选 `goctl` 插件
@ -207,4 +207,4 @@ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/
加我之前有劳点一下 ***star***,一个小小的 ***star*** 是作者们回答海量问题的动力🤝
<img src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/wechat.jpg" alt="wechat" width="300" />
<img src="https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/wechat.jpg" alt="wechat" width="300" />

View File

@ -14,4 +14,4 @@ go-zero 包含极简的 API 定义和生成工具 goctl可以根据定义的
我们目前拥有7000多人的社区成员在这里你可以和大家讨论任何关于go-zero的技术问题反馈获取最新的go-zero信息以及各位大佬每天分享的技术心得。
## go-zero社区群
<img src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/wechat.jpg" width="300" alt="社区群"/>
<img src="https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/wechat.jpg" width="300" alt="社区群"/>

View File

@ -9,7 +9,7 @@ $ vim service/user/cmd/api/internal/config/config.go
```go
package config
import "github.com/tal-tech/go-zero/rest"
import "github.com/zeromicro/go-zero/rest"
type Config struct {
rest.RestConf
@ -121,4 +121,4 @@ func (l *LoginLogic) Login(req types.LoginReq) (*types.LoginReply, error) {
* [goctl api命令](goctl-api.md)
* [api目录结构介绍](api-dir.md)
* [jwt鉴权](jwt.md)
* [api配置介绍](api-config.md)
* [api配置介绍](api-config.md)

View File

@ -38,7 +38,7 @@ cache 实现的建的功能包括
* 缓存击穿
实现原理:
Cache 自动失效,是采用 TimingWheel(https://github.com/tal-tech/zeromicro/blob/master/core/collection/timingwheel.go) 进行管理的
Cache 自动失效,是采用 TimingWheel(https://github.com/zeromicro/zeromicro/blob/master/core/collection/timingwheel.go) 进行管理的
``` go
timingWheel, err := NewTimingWheel(time.Second, slots, func(k, v interface{}) {
@ -79,7 +79,7 @@ Cache 的命中率统计,是在代码中实现 cacheStat,在缓存命中丢失
cache(proc) - qpm: 2, hit_ratio: 50.0%, elements: 0, hit: 1, miss: 1
```
缓存击穿包含是使用 syncx.SharedCalls(https://github.com/tal-tech/zeromicro/blob/master/core/syncx/sharedcalls.go) 进行实现的,就是将同时请求同一个 key 的请求, 关于 sharedcalls 后续会继续补充。 相关具体实现是在:
缓存击穿包含是使用 syncx.SingleFlight(https://github.com/zeromicro/zeromicro/blob/master/core/syncx/singleflight.go) 进行实现的,就是将同时请求同一个 key 的请求, 关于 SingleFlight 后续会继续补充。 相关具体实现是在:
```go
func (c *Cache) Take(key string, fetch func() (interface{}, error)) (interface{}, error) {

View File

@ -784,8 +784,8 @@ Done.
package config
import (
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -809,7 +809,7 @@ import (
"datacenter/common/model"
"datacenter/common/rpc/internal/config"
"github.com/tal-tech/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
type ServiceContext struct {
@ -840,9 +840,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
package config
import (
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -880,12 +880,12 @@ import (
"net/http"
"time"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/core/stores/redis"
"github.com/tal-tech/go-zero/core/syncx"
"github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/core/syncx"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
@ -952,7 +952,7 @@ import (
"datacenter/common/model"
"datacenter/common/rpc/common"
"github.com/tal-tech/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/logx"
)
type AppInfoLogic struct {

View File

@ -20,7 +20,7 @@ import (
"syscall"
"time"
"github.com/tal-tech/go-zero/core/fx"
"github.com/zeromicro/go-zero/core/fx"
)
func main() {

View File

@ -48,8 +48,8 @@
package config
import (
"github.com/tal-tech/go-queue/dq"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-queue/dq"
"github.com/zeromicro/go-zero/core/service"
)
@ -76,7 +76,7 @@
import (
"context"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-zero/core/service"
"job/internal/logic"
"job/internal/svc"
)
@ -105,9 +105,9 @@
import (
"context"
"github.com/tal-tech/go-queue/dq"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/threading"
"github.com/zeromicro/go-queue/dq"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/threading"
"job/internal/svc"
"strconv"
"time"
@ -173,8 +173,8 @@
import (
"context"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/threading"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/threading"
"job/internal/svc"
)
@ -223,7 +223,7 @@
import (
"job/internal/config"
"github.com/tal-tech/go-queue/dq"
"github.com/zeromicro/go-queue/dq"
)
type ServiceContext struct {
@ -257,9 +257,9 @@
import (
"flag"
"fmt"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/service"
"job/internal/config"
"job/internal/handler"
"job/internal/svc"
@ -313,4 +313,4 @@
为什么使用`dq`,需要使用`redis`
- 因为`beanstalk`是单点服务,无法保证高可用。`dq`可以使用多个单点`beanstalk`服务,互相备份 & 保证高可用。使用`redis`解决重复消费问题。
- 因为`beanstalk`是单点服务,无法保证高可用。`dq`可以使用多个单点`beanstalk`服务,互相备份 & 保证高可用。使用`redis`解决重复消费问题。

View File

@ -8,10 +8,10 @@ Goctl在go-zero项目开发着有着很大的作用其可以有效的帮助
* download&install
```shell
# 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 及以后版本
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
```
* 环境变量检测

View File

@ -34,15 +34,15 @@ goctl model 为go-zero下的工具模块中的组件之一目前支持识别m
"strings"
"time"
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/core/stores/sqlc"
"github.com/tal-tech/go-zero/core/stores/sqlx"
"github.com/tal-tech/go-zero/core/stringx"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/sqlc"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
userFieldNames = builderx.RawFieldNames(&User{})
userFieldNames = builder.RawFieldNames(&User{})
userRows = strings.Join(userFieldNames, ",")
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"

View File

@ -23,7 +23,7 @@ ENV TZ Asia/Shanghai
### Dockerfile编写过程
* 首先安装 goctl 工具
```shell
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
* 在 greet 项目下创建一个 hello 服务
@ -141,7 +141,7 @@ goctl 工具极大简化了 Dockerfile 文件的编写,提供了开箱即用
- 首先安装 `goctl` 工具
```shell
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
- 一键生成 K8S 部署文件

View File

@ -19,7 +19,7 @@ package main
import (
"fmt"
"github.com/tal-tech/go-zero/tools/goctl/plugin"
"github.com/zeromicro/go-zero/tools/goctl/plugin"
)
func main() {
@ -59,4 +59,4 @@ type Plugin struct {
* [api目录](api-dir.md)
* [api语法](api-grammar.md)
* [api配置](api-config.md)
* [api命令介绍](goctl-api.md)
* [api命令介绍](goctl-api.md)

View File

@ -46,17 +46,17 @@ goctl version 1.1.5 darwin/amd64
```shell
# 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 及以后版本
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工具安装到 `$GOPATH/bin` 目录下
### 方式二 fork and build
从 go-zero代码仓库 `git@github.com:tal-tech/go-zero.git` 拉取一份源码,进入 `tools/goctl/`目录下编译一下 goctl 文件,然后将其添加到环境变量中。
从 go-zero代码仓库 `git@github.com:zeromicro/go-zero.git` 拉取一份源码,进入 `tools/goctl/`目录下编译一下 goctl 文件,然后将其添加到环境变量中。
安装完成后执行`goctl -v`,如果输出版本信息则代表安装成功,例如:

View File

@ -29,7 +29,7 @@ go-zero 的Pull request中的代码需要满足一定规范
![pr](./resource/new_pr.png)
* `base repository`选择`tal-tech/go-zero` `base:master`,`head repository`选择`xx/go-zero` `compare:$branch` `$branch`为你开发的分支,如图:
* `base repository`选择`zeromicro/go-zero` `base:master`,`head repository`选择`xx/go-zero` `compare:$branch` `$branch`为你开发的分支,如图:
![pr](./resource/compare.png)
@ -50,4 +50,4 @@ go-zero 的Pull request中的代码需要满足一定规范
## 参考文档
* [Github Pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests)
* [Github Pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests)

View File

@ -135,5 +135,5 @@ Clusters:
* [elasticsearch](https://www.elastic.co/cn/elasticsearch/)
* [kibana](https://www.elastic.co/cn/kibana)
* [filebeat](https://www.elastic.co/cn/beats/filebeat)
* [go-stash](https://github.com/tal-tech/go-stash)
* [go-stash](https://github.com/kevwan/go-stash)
* [filebeat配置](https://www.elastic.co/guide/en/beats/filebeat/current/index.html)

View File

@ -79,7 +79,7 @@ logx.Close()
推荐写法:
```go
import "github.com/tal-tech/go-zero/core/proc"
import "github.com/zeromicro/go-zero/core/proc"
// grace close log
proc.AddShutdownListener(func() {

View File

@ -99,7 +99,7 @@ $ mkdir mall && cd mall
"go-zero-demo/mall/user/rpc/internal/svc"
"go-zero-demo/mall/user/rpc/user"
"github.com/tal-tech/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserLogic struct {
@ -133,7 +133,7 @@ $ mkdir mall && cd mall
package config
import (
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -201,8 +201,8 @@ $ mkdir mall && cd mall
```go
package config
import "github.com/tal-tech/go-zero/rest"
import "github.com/tal-tech/go-zero/zrpc"
import "github.com/zeromicro/go-zero/rest"
import "github.com/zeromicro/go-zero/zrpc"
type Config struct {
rest.RestConf
@ -236,7 +236,7 @@ $ mkdir mall && cd mall
"go-zero-demo/mall/order/api/internal/config"
"go-zero-demo/mall/user/rpc/userclient"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/zrpc"
)
type ServiceContext struct {

View File

@ -50,7 +50,7 @@ func NewMysqlModel(conn sqlx.SqlConn, table string) *MysqlModel {
准备一个 `User model`
```go
var userBuilderQueryRows = strings.Join(builderx.FieldNames(&User{}), ",")
var userBuilderQueryRows = strings.Join(builder.FieldNames(&User{}), ",")
type User struct {
Avatar string `db:"avatar"` // 头像

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 557 KiB

After

Width:  |  Height:  |  Size: 557 KiB

View File

@ -76,7 +76,7 @@
* 安装 goctl 工具
```shell
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
* 创建工作目录 `shorturl``shorturl/api`
@ -95,7 +95,7 @@
require (
github.com/golang/mock v1.4.3
github.com/golang/protobuf v1.4.2
github.com/tal-tech/go-zero v1.1.4
github.com/zeromicro/go-zero v1.3.0
golang.org/x/net v0.0.0-20200707034311-ab3426394381
google.golang.org/grpc v1.29.1
)
@ -520,13 +520,13 @@
至此代码修改完成,凡是手动修改的代码我加了标注
**注意:**
1. undefined cache你需要 `import "github.com/tal-tech/go-zero/core/stores/cache"`
1. undefined cache你需要 `import "github.com/zeromicro/go-zero/core/stores/cache"`
2. undefined model, sqlx, hash 等,你需要在文件中
```golang
import "shorturl/rpc/transform/model"
import "github.com/tal-tech/go-zero/core/stores/sqlx"
import "github.com/zeromicro/go-zero/core/stores/sqlx"
```
## 10. 完整调用演示

View File

@ -16,7 +16,7 @@ import (
"syscall"
"time"
"github.com/tal-tech/go-zero/core/fx"
"github.com/zeromicro/go-zero/core/fx"
)
func main() {

View File

@ -30,7 +30,7 @@ package response
import (
"net/http"
"github.com/tal-tech/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/rest/httpx"
)
type Body struct {

View File

@ -63,8 +63,8 @@ import (
"example/zrpc/pb"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
@ -107,8 +107,8 @@ import (
"example/zrpc/pb"
"github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/discov"
"github.com/zeromicro/go-zero/zrpc"
)
func main() {

View File

@ -1,11 +1,11 @@
<img align="right" width="150px" src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/go-zero.png">
<img align="right" width="150px" src="https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/go-zero.png">
# go-zero ![GitHub Repo stars](https://img.shields.io/github/stars/tal-tech/go-zero?style=social) ![GitHub forks](https://img.shields.io/github/forks/tal-tech/go-zero?style=social)
# go-zero ![GitHub Repo stars](https://img.shields.io/github/stars/zeromicro/go-zero?style=social) ![GitHub forks](https://img.shields.io/github/forks/zeromicro/go-zero?style=social)
[![Go](https://github.com/zeromicro/go-zero/workflows/Go/badge.svg?branch=master)](https://github.com/zeromicro/go-zero/actions)
[![codecov](https://codecov.io/gh/zeromicro/go-zero/branch/master/graph/badge.svg)](https://codecov.io/gh/zeromicro/go-zero)
[![Go Report Card](https://goreportcard.com/badge/github.com/tal-tech/go-zero)](https://goreportcard.com/report/github.com/tal-tech/go-zero)
[![Release](https://img.shields.io/github/v/release/tal-tech/go-zero.svg?style=flat-square)](https://github.com/zeromicro/go-zero)
[![Go Report Card](https://goreportcard.com/badge/github.com/zeromicro/go-zero)](https://goreportcard.com/report/github.com/zeromicro/go-zero)
[![Release](https://img.shields.io/github/v/release/zeromicro/go-zero.svg?style=flat-square)](https://github.com/zeromicro/go-zero)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
## 0. what is go-zero
@ -23,7 +23,7 @@ Advantages of go-zero:
* auto validate the request parameters from clients
* plenty of builtin microservice management and concurrent toolkits
<img src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/architecture-en.png" alt="Architecture" width="1500" />
<img src="https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/architecture-en.png" alt="Architecture" width="1500" />
## 1. Backgrounds of go-zero
@ -74,7 +74,7 @@ go-zero is a web and rpc framework that integrates lots of engineering practices
As below, go-zero protects the system with couple layers and mechanisms:
![Resilience](https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/resilience-en.png)
![Resilience](https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/resilience-en.png)
## 4. Future development plans of go-zero
@ -86,23 +86,23 @@ As below, go-zero protects the system with couple layers and mechanisms:
Run the following command under your project:
```shell
go get -u github.com/tal-tech/go-zero
go get -u github.com/zeromicro/go-zero
```
## 6. Quick Start
0. full examples can be checked out from below:
[Rapid development of microservice systems](https://github.com/tal-tech/zero-doc/blob/main/doc/shorturl-en.md)
[Rapid development of microservice systems](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl-en.md)
[Rapid development of microservice systems - multiple RPCs](https://github.com/tal-tech/zero-doc/blob/main/doc/bookstore-en.md)
[Rapid development of microservice systems - multiple RPCs](https://github.com/zeromicro/zero-doc/blob/main/doc/bookstore-en.md)
1. install goctl
`goctl`can be read as `go control`. `goctl` means not to be controlled by code, instead, we control it. The inside `go` is not `golang`. At the very beginning, I was expecting it to help us improve the productivity, and make our lives easier.
```shell
GO111MODULE=on go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on go get -u github.com/zeromicro/go-zero/tools/goctl
```
make sure goctl is executable.
@ -198,14 +198,14 @@ go get -u github.com/tal-tech/go-zero
## 7. Benchmark
![benchmark](https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/benchmark.png)
![benchmark](https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/benchmark.png)
[Checkout the test code](https://github.com/smallnest/go-web-framework-benchmark)
## 8. Documents (adding)
* [Rapid development of microservice systems](https://github.com/tal-tech/zero-doc/blob/main/doc/shorturl-en.md)
* [Rapid development of microservice systems - multiple RPCs](https://github.com/tal-tech/zero-doc/blob/main/docs/zero/bookstore-en.md)
* [Rapid development of microservice systems](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl-en.md)
* [Rapid development of microservice systems - multiple RPCs](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/bookstore-en.md)
* [Examples](https://github.com/zeromicro/zero-examples)
## 9. Important notes

View File

@ -13,7 +13,7 @@ $ vim service/user/cmd/api/internal/config/config.go
```go
package config
import "github.com/tal-tech/go-zero/rest"
import "github.com/zeromicro/go-zero/rest"
type Config struct {
rest.RestConf
@ -125,4 +125,4 @@ func (l *LoginLogic) Login(req types.LoginReq) (*types.LoginReply, error) {
* [API Commands](goctl-api.md)
* [API Directory Structure](api-dir.md)
* [JWT](jwt.md)
* [API Configuration](api-config.md)
* [API Configuration](api-config.md)

View File

@ -649,8 +649,8 @@ So the basic `rpc` is finished, and then we connect the rpc with the model and t
package config
import (
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -674,7 +674,7 @@ import (
"datacenter/common/model"
"datacenter/common/rpc/internal/config"
"github.com/tal-tech/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
type ServiceContext struct {
@ -705,9 +705,9 @@ The above code has already associated `rpc` with the `model` database, we will n
package config
import (
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -745,12 +745,12 @@ import (
"net/http"
"time"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/core/stores/redis"
"github.com/tal-tech/go-zero/core/syncx"
"github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/core/syncx"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
@ -817,7 +817,7 @@ import (
"datacenter/common/model"
"datacenter/common/rpc/common"
"github.com/tal-tech/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/logx"
)
type AppInfoLogic struct {

View File

@ -48,8 +48,8 @@ In the development of daily tasks, we will have many asynchronous, batch, timing
package config
import (
"github.com/tal-tech/go-queue/dq"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-queue/dq"
"github.com/zeromicro/go-zero/core/service"
)
@ -76,7 +76,7 @@ In the development of daily tasks, we will have many asynchronous, batch, timing
import (
"context"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-zero/core/service"
"job/internal/logic"
"job/internal/svc"
)
@ -107,9 +107,9 @@ In the development of daily tasks, we will have many asynchronous, batch, timing
import (
"context"
"github.com/tal-tech/go-queue/dq"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/threading"
"github.com/zeromicro/go-queue/dq"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/threading"
"job/internal/svc"
"strconv"
"time"
@ -175,8 +175,8 @@ In the development of daily tasks, we will have many asynchronous, batch, timing
import (
"context"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/threading"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/threading"
"job/internal/svc"
)
@ -225,7 +225,7 @@ In the development of daily tasks, we will have many asynchronous, batch, timing
import (
"job/internal/config"
"github.com/tal-tech/go-queue/dq"
"github.com/zeromicro/go-queue/dq"
)
type ServiceContext struct {
@ -259,9 +259,9 @@ In the development of daily tasks, we will have many asynchronous, batch, timing
import (
"flag"
"fmt"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/service"
"job/internal/config"
"job/internal/handler"
"job/internal/svc"

View File

@ -11,10 +11,10 @@ Here we strongly recommend that you install it, because most of the follow-up de
* download&install
```shell
# Go 1.15 及之前版本
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
# Go 1.16 及以后版本
go install github.com/tal-tech/go-zero/tools/goctl@latest
go install github.com/zeromicro/go-zero/tools/goctl@latest
```
* Environmental variable detection

View File

@ -36,15 +36,15 @@ goctl model is one of the components in the tool module under go-zero. It curren
"strings"
"time"
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/core/stores/sqlc"
"github.com/tal-tech/go-zero/core/stores/sqlx"
"github.com/tal-tech/go-zero/core/stringx"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/sqlc"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
userFieldNames = builderx.RawFieldNames(&User{})
userFieldNames = builder.RawFieldNames(&User{})
userRows = strings.Join(userFieldNames, ",")
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
@ -373,4 +373,4 @@ For the cache, I chose to list it in the form of question and answer. I think th
| longtext | string | sql.NullString |
| enum | string | sql.NullString |
| set | string | sql.NullString |
| json | string | sql.NullString |
| json | string | sql.NullString |

View File

@ -26,7 +26,7 @@ ENV TZ Asia/Shanghai
### Dockerfile writing process
* First install the goctl tool
```shell
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
* Create a hello service under the greet project
@ -144,7 +144,7 @@ For demonstration, here we take the `redis:6-alpine` image as an example.
- First install the `goctl` tool
```shell
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
- One-click generation of K8S deployment files
@ -308,4 +308,4 @@ The `goctl` tool greatly simplifies the writing of K8S yaml files, provides best
* [API Configuration](api-config.md)
* [API Commands](goctl-api.md)
* [Docker](https://www.docker.com)
* [K8s](https://kubernetes.io/docs/home/)
* [K8s](https://kubernetes.io/docs/home/)

View File

@ -21,7 +21,7 @@ package main
import (
"fmt"
"github.com/tal-tech/go-zero/tools/goctl/plugin"
"github.com/zeromicro/go-zero/tools/goctl/plugin"
)
func main() {
@ -61,4 +61,4 @@ Complete android plugin demo project based on plugin
* [API Directory Structure](api-dir.md)
* [API IDL](api-grammar.md)
* [API Configuration](api-config.md)
* [API Commands](goctl-api.md)
* [API Commands](goctl-api.md)

View File

@ -47,14 +47,14 @@ Version number description
### The way onego get
```shell
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
$ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
Use this command to install the goctl tool into the `GOPATHbin` directory
### The way two fork and build
Pull a source code from the go-zero code repository `git@github.com:tal-techgo-zero.git`, enter the `toolsgoctl` directory to compile the goctl file, and then add it to the environment variable.
Pull a source code from the go-zero code repository `git@github.com:zeromicro/go-zero.git`, enter the `tools/goctl` directory to compile the goctl file, and then add it to the environment variable.
After the installation is complete, execute `goctl -v`. If the version information is output, the installation is successful, for example:

View File

@ -32,7 +32,7 @@ The code in go-zero's Pull request needs to meet certain specifications
![pr](./resource/new_pr.png)
* `base repository` choose `tal-tech/go-zero` `base:master`,`head repository` choose `xx/go-zero` `compare:$branch` `$branch` is the branch you developed, as shown in the figure:
* `base repository` choose `zeromicro/go-zero` `base:master`,`head repository` choose `xx/go-zero` `compare:$branch` `$branch` is the branch you developed, as shown in the figure:
![pr](./resource/compare.png)
@ -58,4 +58,4 @@ You can also get the latest trend of go-zero here, and welcome everyone Come and
## Reference
* [Github Pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests)
* [Github Pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests)

View File

@ -140,5 +140,5 @@ Enter 127.0.0.1:5601
* [elasticsearch](https://www.elastic.co/cn/elasticsearch/)
* [kibana](https://www.elastic.co/cn/kibana)
* [filebeat](https://www.elastic.co/cn/beats/filebeat)
* [go-stash](https://github.com/tal-tech/go-stash)
* [go-stash](https://github.com/kevwan/go-stash)
* [filebeat](https://www.elastic.co/guide/en/beats/filebeat/current/index.html)

View File

@ -79,7 +79,7 @@ At the same time, note that when the log output is turned off, the log cannot be
Recommended writing:
```go
import "github.com/tal-tech/go-zero/core/proc"
import "github.com/zeromicro/go-zero/core/proc"
// grace close log
proc.AddShutdownListener(func() {

View File

@ -98,7 +98,7 @@ $ mkdir mall && cd mall
"go-zero-demo/mall/user/internal/svc"
"go-zero-demo/mall/user/user"
"github.com/tal-tech/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserLogic struct {
@ -131,7 +131,7 @@ $ mkdir mall && cd mall
package config
import (
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -198,8 +198,8 @@ $ mkdir mall && cd mall
```go
package config
import "github.com/tal-tech/go-zero/rest"
import "github.com/tal-tech/go-zero/zrpc"
import "github.com/zeromicro/go-zero/rest"
import "github.com/zeromicro/go-zero/zrpc"
type Config struct {
rest.RestConf
@ -233,7 +233,7 @@ $ mkdir mall && cd mall
"go-zero-demo/mall/order/api/internal/config"
"go-zero-demo/mall/user/rpc/userclient"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/zrpc"
)
type ServiceContext struct {

View File

@ -52,7 +52,7 @@ func NewMysqlModel(conn sqlx.SqlConn, table string) *MysqlModel {
Prepare an `User model`
```go
var userBuilderQueryRows = strings.Join(builderx.FieldNames(&User{}), ",")
var userBuilderQueryRows = strings.Join(builder.FieldNames(&User{}), ",")
type User struct {
Avatar string `db:"avatar"`

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 557 KiB

After

Width:  |  Height:  |  Size: 557 KiB

View File

@ -69,7 +69,7 @@ And now, lets walk through the complete flow of quickly create a microservice
* install goctl
```shell
GO111MODULE=on go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on go get -u github.com/zeromicro/go-zero/tools/goctl
```
* create the working dir `shorturl` and `shorturl/api`
@ -88,7 +88,7 @@ And now, lets walk through the complete flow of quickly create a microservice
require (
github.com/golang/mock v1.4.3
github.com/golang/protobuf v1.4.2
github.com/tal-tech/go-zero v1.1.4
github.com/zeromicro/go-zero v1.3.0
golang.org/x/net v0.0.0-20200707034311-ab3426394381
google.golang.org/grpc v1.29.1
)

View File

@ -18,7 +18,7 @@ import (
"syscall"
"time"
"github.com/tal-tech/go-zero/core/fx"
"github.com/zeromicro/go-zero/core/fx"
)
func main() {

View File

@ -31,7 +31,7 @@ package response
import (
"net/http"
"github.com/tal-tech/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/rest/httpx"
)
type Body struct {
@ -161,4 +161,4 @@ This document only describes the process of customizing the template for the cor
* model layer adds kmq
* model layer to generate the model instance of the option to be valid
* http customize the corresponding format
...
...

View File

@ -64,7 +64,7 @@ Judging from the definition structure of `span`: In microservices, this is a com
## Example application
In `go-zero`, http and rpc have been integrated as built-in middleware. We use [http](https://github.com/zeromicro/go-zero/blob/master/rest/handler/tracinghandler.go), [rpc](https://github.com/tal-tech /go-zero/blob/master/zrpc/internal/clientinterceptors/tracinginterceptor.go), take a look at how `tracing` is used:
In `go-zero`, http and rpc have been integrated as built-in middleware. We use [http](https://github.com/zeromicro/go-zero/blob/master/rest/handler/tracinghandler.go), [rpc](https://github.com/zeromicro/go-zero/blob/master/zrpc/internal/clientinterceptors/tracinginterceptor.go), take a look at how `tracing` is used:
### HTTP
@ -185,4 +185,4 @@ At the same time, `go-zero` does not provide a complete set of `trace` link solu
## Reference
- [go-zero trace](https://github.com/zeromicro/go-zero/tree/master/core/trace)
- [go-zero trace](https://github.com/zeromicro/go-zero/tree/master/core/trace)

View File

@ -91,7 +91,7 @@ As below, go-zero protects the system with couple layers and mechanisms:
Run the following command under your project:
```shell
go get -u github.com/tal-tech/go-zero
go get -u github.com/zeromicro/go-zero
```
## 6. Quick Start
@ -107,7 +107,7 @@ go get -u github.com/tal-tech/go-zero
`goctl`can be read as `go control`. `goctl` means not to be controlled by code, instead, we control it. The inside `go` is not `golang`. At the very beginning, I was expecting it to help us improve the productivity, and make our lives easier.
```shell
GO111MODULE=on go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on go get -u github.com/zeromicro/go-zero/tools/goctl
```
make sure goctl is executable.

View File

@ -38,15 +38,15 @@ sidebar_position: 4
"strings"
"time"
"github.com/tal-tech/go-zero/core/stores/builder"
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/core/stores/sqlc"
"github.com/tal-tech/go-zero/core/stores/sqlx"
"github.com/tal-tech/go-zero/core/stringx"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx"
)
var (
userFieldNames = builderx.RawFieldNames(&User{})
userFieldNames = builder.RawFieldNames(&User{})
userRows = strings.Join(userFieldNames, ",")
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
@ -376,4 +376,4 @@ goctl model mysql ddl/datasource 均新增了一个`--style`参数,用于标
| longtext | string | sql.NullString |
| enum | string | sql.NullString |
| set | string | sql.NullString |
| json | string | sql.NullString |
| json | string | sql.NullString |

View File

@ -24,7 +24,7 @@ package main
import (
"fmt"
"github.com/tal-tech/go-zero/tools/goctl/plugin"
"github.com/zeromicro/go-zero/tools/goctl/plugin"
)
func main() {
@ -62,4 +62,4 @@ Dir工作目录
完整的基于plugin实现的android plugin演示项目
[https://github.com/zeromicro/goctl-android](https://github.com/zeromicro/goctl-android)
[https://github.com/zeromicro/goctl-android](https://github.com/zeromicro/goctl-android)

View File

@ -156,7 +156,7 @@ package response
import (
"net/http"
"github.com/tal-tech/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/rest/httpx"
)
type Body struct {

View File

@ -57,7 +57,7 @@ docker run \
上面例子中的请求方式是 `HTTP`,也就是在请求服务端时,监控指标数据不断被搜集。很容易想到是 中间件 的功能,具体代码:
```go title="https://github.com/tal-tech/go-zero/blob/master/rest/handler/prometheushandler.go"
```go title="https://github.com/zeromicro/go-zero/blob/master/rest/handler/prometheushandler.go"
var (
metricServerReqDur = metric.NewHistogramVec(&metric.HistogramVecOpts{
...
@ -107,7 +107,7 @@ func PromethousHandler(path string) func(http.Handler) http.Handler {
`go-zero` 中也提供了 `prometheus metric` 基本封装,供开发者自己开发自己 prometheus 中间件。
:::tip
代码https://github.com/tal-tech/go-zero/tree/master/core/metric
代码https://github.com/zeromicro/go-zero/tree/master/core/metric
:::
| 名称 | 用途 | 搜集函数 |

View File

@ -42,7 +42,7 @@ cache 实现的建的功能包括
* 缓存击穿
实现原理:
Cache 自动失效,是采用 TimingWheel(https://github.com/tal-tech/zeromicro/blob/master/core/collection/timingwheel.go) 进行管理的
Cache 自动失效,是采用 TimingWheel(https://github.com/zeromicro/zeromicro/blob/master/core/collection/timingwheel.go) 进行管理的
``` go
timingWheel, err := NewTimingWheel(time.Second, slots, func(k, v interface{}) {
@ -83,7 +83,7 @@ Cache 的命中率统计,是在代码中实现 cacheStat,在缓存命中丢失
cache(proc) - qpm: 2, hit_ratio: 50.0%, elements: 0, hit: 1, miss: 1
```
缓存击穿包含是使用 syncx.SharedCalls(https://github.com/tal-tech/zeromicro/blob/master/core/syncx/sharedcalls.go) 进行实现的,就是将同时请求同一个 key 的请求, 关于 sharedcalls 后续会继续补充。 相关具体实现是在:
缓存击穿包含是使用 syncx.SingleFlight(https://github.com/zeromicro/zeromicro/blob/master/core/syncx/singleflight.go) 进行实现的,就是将同时请求同一个 key 的请求, 关于 SingleFlight 后续会继续补充。 相关具体实现是在:
```go
func (c *Cache) Take(key string, fetch func() (interface{}, error)) (interface{}, error) {

View File

@ -788,8 +788,8 @@ Done.
package config
import (
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -813,7 +813,7 @@ import (
"datacenter/common/model"
"datacenter/common/rpc/internal/config"
"github.com/tal-tech/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
type ServiceContext struct {
@ -844,9 +844,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
package config
import (
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -884,12 +884,12 @@ import (
"net/http"
"time"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/core/stores/redis"
"github.com/tal-tech/go-zero/core/syncx"
"github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/core/syncx"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
@ -956,7 +956,7 @@ import (
"datacenter/common/model"
"datacenter/common/rpc/common"
"github.com/tal-tech/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/logx"
)
type AppInfoLogic struct {

View File

@ -24,7 +24,7 @@ import (
"syscall"
"time"
"github.com/tal-tech/go-zero/core/fx"
"github.com/zeromicro/go-zero/core/fx"
)
func main() {

View File

@ -50,8 +50,8 @@ sidebar_position: 22
package config
import (
"github.com/tal-tech/go-queue/dq"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-queue/dq"
"github.com/zeromicro/go-zero/core/service"
)
@ -78,7 +78,7 @@ sidebar_position: 22
import (
"context"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-zero/core/service"
"job/internal/logic"
"job/internal/svc"
)
@ -107,9 +107,9 @@ sidebar_position: 22
import (
"context"
"github.com/tal-tech/go-queue/dq"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/threading"
"github.com/zeromicro/go-queue/dq"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/threading"
"job/internal/svc"
"strconv"
"time"
@ -175,8 +175,8 @@ sidebar_position: 22
import (
"context"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/threading"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/threading"
"job/internal/svc"
)
@ -225,7 +225,7 @@ sidebar_position: 22
import (
"job/internal/config"
"github.com/tal-tech/go-queue/dq"
"github.com/zeromicro/go-queue/dq"
)
type ServiceContext struct {
@ -259,9 +259,9 @@ sidebar_position: 22
import (
"flag"
"fmt"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/service"
"job/internal/config"
"job/internal/handler"
"job/internal/svc"
@ -315,4 +315,4 @@ sidebar_position: 22
为什么使用`dq`,需要使用`redis`
- 因为`beanstalk`是单点服务,无法保证高可用。`dq`可以使用多个单点`beanstalk`服务,互相备份 & 保证高可用。使用`redis`解决重复消费问题。
- 因为`beanstalk`是单点服务,无法保证高可用。`dq`可以使用多个单点`beanstalk`服务,互相备份 & 保证高可用。使用`redis`解决重复消费问题。

View File

@ -82,7 +82,7 @@ logx.Close()
推荐写法:
```go
import "github.com/tal-tech/go-zero/core/proc"
import "github.com/zeromicro/go-zero/core/proc"
// grace close log
proc.AddShutdownListener(func() {

View File

@ -54,7 +54,7 @@ func NewMysqlModel(conn sqlx.SqlConn, table string) *MysqlModel {
准备一个 `User model`
```go
var userBuilderQueryRows = strings.Join(builderx.FieldNames(&User{}), ",")
var userBuilderQueryRows = strings.Join(builder.FieldNames(&User{}), ",")
type User struct {
Avatar string `db:"avatar"` // 头像

View File

@ -78,7 +78,7 @@ sidebar_position: 0
* 安装 goctl 工具
```shell
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
* 创建工作目录 `shorturl``shorturl/api`
@ -97,7 +97,7 @@ sidebar_position: 0
require (
github.com/golang/mock v1.4.3
github.com/golang/protobuf v1.4.2
github.com/tal-tech/go-zero v1.1.4
github.com/zeromicro/go-zero v1.1.4
golang.org/x/net v0.0.0-20200707034311-ab3426394381
google.golang.org/grpc v1.29.1
)
@ -522,13 +522,13 @@ sidebar_position: 0
至此代码修改完成,凡是手动修改的代码我加了标注
**注意:**
1. undefined cache你需要 `import "github.com/tal-tech/go-zero/core/stores/cache"`
1. undefined cache你需要 `import "github.com/zeromicro/go-zero/core/stores/cache"`
2. undefined model, sqlx, hash 等,你需要在文件中
```golang
import "shorturl/rpc/transform/model"
import "github.com/tal-tech/go-zero/core/stores/sqlx"
import "github.com/zeromicro/go-zero/core/stores/sqlx"
```
## 完整调用演示

View File

@ -20,7 +20,7 @@ import (
"syscall"
"time"
"github.com/tal-tech/go-zero/core/fx"
"github.com/zeromicro/go-zero/core/fx"
)
func main() {

View File

@ -65,8 +65,8 @@ import (
"example/zrpc/pb"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
@ -109,8 +109,8 @@ import (
"example/zrpc/pb"
"github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/discov"
"github.com/zeromicro/go-zero/zrpc"
)
func main() {

View File

@ -23,4 +23,4 @@ go-zero 包含极简的 API 定义和生成工具 goctl可以根据定义的
我们目前拥有7000多人的社区成员在这里你可以和大家讨论任何关于go-zero的技术问题反馈获取最新的go-zero信息以及各位大佬每天分享的技术心得。
## go-zero社区群
<img src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/wechat.jpg" width="300" alt="社区群"/>
<img src="https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/wechat.jpg" width="300" alt="社区群"/>

View File

@ -81,16 +81,16 @@ go-zero 是一个集成了各种工程实践的包含 web 和 rpc 框架,有
在项目目录下通过如下命令安装:
```md
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
```
## Quick Start
#### 完整示例请查看
[快速构建高并发微服务](https://github.com/tal-tech/zero-doc/blob/main/doc/shorturl.md)
[快速构建高并发微服务](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl.md)
[快速构建高并发微服务 - 多 RPC 版](https://github.com/tal-tech/zero-doc/blob/main/docs/zero/bookstore.md)
[快速构建高并发微服务 - 多 RPC 版](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/bookstore.md)
#### 安装 `goctl` 工具
@ -98,13 +98,13 @@ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/
来解放我们的双手👈
```shell
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
如果使用 go1.16 版本, 可以使用 `go install` 命令安装
```shell
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` 可执行
@ -157,8 +157,8 @@ goctl api dart -api greet.api -dir greet
[测试代码见这里](https://github.com/smallnest/go-web-framework-benchmark)
* awesome 系列(更多文章见『微服务实践』公众号)
* [快速构建高并发微服务](https://github.com/tal-tech/zero-doc/blob/main/doc/shorturl.md)
* [快速构建高并发微服务 - 多 RPC 版](https://github.com/tal-tech/zero-doc/blob/main/docs/zero/bookstore.md)
* [快速构建高并发微服务](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl.md)
* [快速构建高并发微服务 - 多 RPC 版](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/bookstore.md)
* 精选 `goctl` 插件
@ -195,4 +195,4 @@ goctl api dart -api greet.api -dir greet
加我之前有劳点一下 ***star***,一个小小的 ***star*** 是作者们回答海量问题的动力🤝
<img src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/wechat.jpg" alt="wechat" width="300" />
<img src="https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/wechat.jpg" alt="wechat" width="300" />

View File

@ -34,7 +34,7 @@ go-zero 的Pull request中的代码需要满足一定规范
![pr](/img/new_pr.png)
* `base repository`选择`tal-tech/go-zero` `base:master`,`head repository`选择`xx/go-zero` `compare:$branch` `$branch`为你开发的分支,如图:
* `base repository`选择`zeromicro/go-zero` `base:master`,`head repository`选择`xx/go-zero` `compare:$branch` `$branch`为你开发的分支,如图:
![pr](/img/compare.png)

View File

@ -133,7 +133,7 @@ consumer
分为 cluster 和 node。cluster
`https://github.com/tal-tech/go-queue/blob/master/dq/consumer.go#L45`
`https://github.com/zeromicro/go-queue/blob/master/dq/consumer.go#L45`
- cluster 内部将 consume handler 做了一层再封装
- 对 consume body 做hash并使用此 hash 作为 redis 去重的key
@ -141,7 +141,7 @@ consumer
#### node
`https://github.com/tal-tech/go-queue/blob/master/dq/consumernode.go#L36`
`https://github.com/zeromicro/go-queue/blob/master/dq/consumernode.go#L36`
- 消费 node 获取到 ready job先执行 Reserve(TTR)预订此job将执行该job进行逻辑处理
- 在 node 中 delete(job);然后再进行消费

View File

@ -346,8 +346,8 @@ import (
"log"
"time"
"github.com/tal-tech/go-zero/core/mr"
"github.com/tal-tech/go-zero/core/timex"
"github.com/zeromicro/go-zero/core/mr"
"github.com/zeromicro/go-zero/core/timex"
)
type user struct{}

View File

@ -259,7 +259,7 @@ $ vim service/user/cmd/api/internal/config/config.go
```go
package config
import "github.com/tal-tech/go-zero/rest"
import "github.com/zeromicro/go-zero/rest"
type Config struct {
rest.RestConf

View File

@ -103,10 +103,10 @@ Goctl在go-zero项目开发着有着很大的作用其可以有效的帮助
* download&install
```shell
# 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 及以后版本
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
```
* 环境变量检测
@ -183,4 +183,4 @@ $GOPATH为你本机的实际文件夹地址
* [etcd](https://etcd.io/docs/current/rfc/v3api/)
* [redis](https://redis.io/)
* [mysql](https://www.mysql.com/)
* [mysql](https://www.mysql.com/)

View File

@ -70,7 +70,7 @@ sidebar_position: 4
"go-zero-demo/mall/user/rpc/internal/svc"
"go-zero-demo/mall/user/rpc/user"
"github.com/tal-tech/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserLogic struct {
@ -104,7 +104,7 @@ sidebar_position: 4
package config
import (
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -147,4 +147,4 @@ sidebar_position: 4
$ go run user.go -f etc/user.yaml
```
```text
Starting rpc server at 127.0.0.1:8080...
Starting rpc server at 127.0.0.1:8080...

View File

@ -39,15 +39,15 @@ $ goctl model mysql datasource -url="user:password@tcp(127.0.0.1:3306)/database"
"strings"
"time"
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/core/stores/sqlc"
"github.com/tal-tech/go-zero/core/stores/sqlx"
"github.com/tal-tech/go-zero/core/stringx"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/sqlc"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
userFieldNames = builderx.RawFieldNames(&User{})
userFieldNames = builder.RawFieldNames(&User{})
userRows = strings.Join(userFieldNames, ",")
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"

View File

@ -27,7 +27,7 @@ package main
import (
"fmt"
"github.com/tal-tech/go-zero/tools/goctl/plugin"
"github.com/zeromicro/go-zero/tools/goctl/plugin"
)
func main() {

View File

@ -169,7 +169,7 @@ package response
import (
"net/http"
"github.com/tal-tech/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/rest/httpx"
)
type Body struct {

View File

@ -57,7 +57,7 @@ For basic access to the above, see our other article: https://zeromicro.github.i
The request method in the above example is `HTTP`, which means that the monitoring metrics data is continuously collected when requesting the server side. It is easy to think of the middleware function, the specific code.
```go title="https://github.com/tal-tech/go-zero/blob/master/rest/handler/prometheushandler.go"
```go title="https://github.com/zeromicro/go-zero/blob/master/rest/handler/prometheushandler.go"
var (
metricServerReqDur = metric.NewHistogramVec(&metric.HistogramVecOpts{
...
@ -108,7 +108,7 @@ The whole thing is actually quite simple.
The `go-zero` also provides the `prometheus metric` basic wrapper for developers to develop their own prometheus middleware.
:::tip
codehttps://github.com/tal-tech/go-zero/tree/master/core/metric
codehttps://github.com/zeromicro/go-zero/tree/master/core/metric
:::
| Name | Usage | Search Functions |

View File

@ -42,7 +42,7 @@ cache 实现的建的功能包括
* 缓存击穿
实现原理:
Cache 自动失效,是采用 TimingWheel(https://github.com/tal-tech/zeromicro/blob/master/core/collection/timingwheel.go) 进行管理的
Cache 自动失效,是采用 TimingWheel(https://github.com/zeromicro/zeromicro/blob/master/core/collection/timingwheel.go) 进行管理的
``` go
timingWheel, err := NewTimingWheel(time.Second, slots, func(k, v interface{}) {
@ -83,7 +83,7 @@ Cache 的命中率统计,是在代码中实现 cacheStat,在缓存命中丢失
cache(proc) - qpm: 2, hit_ratio: 50.0%, elements: 0, hit: 1, miss: 1
```
缓存击穿包含是使用 syncx.SharedCalls(https://github.com/tal-tech/zeromicro/blob/master/core/syncx/sharedcalls.go) 进行实现的,就是将同时请求同一个 key 的请求, 关于 sharedcalls 后续会继续补充。 相关具体实现是在:
缓存击穿包含是使用 syncx.SingleFlight(https://github.com/zeromicro/zeromicro/blob/master/core/syncx/singleflight.go) 进行实现的,就是将同时请求同一个 key 的请求, 关于 SingleFlight 后续会继续补充。 相关具体实现是在:
```go
func (c *Cache) Take(key string, fetch func() (interface{}, error)) (interface{}, error) {

View File

@ -788,8 +788,8 @@ Done.
package config
import (
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -813,7 +813,7 @@ import (
"datacenter/common/model"
"datacenter/common/rpc/internal/config"
"github.com/tal-tech/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
type ServiceContext struct {
@ -844,9 +844,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
package config
import (
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
@ -884,12 +884,12 @@ import (
"net/http"
"time"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/core/stores/redis"
"github.com/tal-tech/go-zero/core/syncx"
"github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/core/syncx"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
@ -956,7 +956,7 @@ import (
"datacenter/common/model"
"datacenter/common/rpc/common"
"github.com/tal-tech/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/logx"
)
type AppInfoLogic struct {

View File

@ -24,7 +24,7 @@ import (
"syscall"
"time"
"github.com/tal-tech/go-zero/core/fx"
"github.com/zeromicro/go-zero/core/fx"
)
func main() {

View File

@ -50,8 +50,8 @@ sidebar_position: 22
package config
import (
"github.com/tal-tech/go-queue/dq"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-queue/dq"
"github.com/zeromicro/go-zero/core/service"
)
@ -78,7 +78,7 @@ sidebar_position: 22
import (
"context"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-zero/core/service"
"job/internal/logic"
"job/internal/svc"
)
@ -107,9 +107,9 @@ sidebar_position: 22
import (
"context"
"github.com/tal-tech/go-queue/dq"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/threading"
"github.com/zeromicro/go-queue/dq"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/threading"
"job/internal/svc"
"strconv"
"time"
@ -175,8 +175,8 @@ sidebar_position: 22
import (
"context"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/threading"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/threading"
"job/internal/svc"
)
@ -225,7 +225,7 @@ sidebar_position: 22
import (
"job/internal/config"
"github.com/tal-tech/go-queue/dq"
"github.com/zeromicro/go-queue/dq"
)
type ServiceContext struct {
@ -259,9 +259,9 @@ sidebar_position: 22
import (
"flag"
"fmt"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/service"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/service"
"job/internal/config"
"job/internal/handler"
"job/internal/svc"
@ -315,4 +315,4 @@ sidebar_position: 22
为什么使用`dq`,需要使用`redis`
- 因为`beanstalk`是单点服务,无法保证高可用。`dq`可以使用多个单点`beanstalk`服务,互相备份 & 保证高可用。使用`redis`解决重复消费问题。
- 因为`beanstalk`是单点服务,无法保证高可用。`dq`可以使用多个单点`beanstalk`服务,互相备份 & 保证高可用。使用`redis`解决重复消费问题。

View File

@ -82,7 +82,7 @@ logx.Close()
推荐写法:
```go
import "github.com/tal-tech/go-zero/core/proc"
import "github.com/zeromicro/go-zero/core/proc"
// grace close log
proc.AddShutdownListener(func() {

View File

@ -54,7 +54,7 @@ func NewMysqlModel(conn sqlx.SqlConn, table string) *MysqlModel {
准备一个 `User model`
```go
var userBuilderQueryRows = strings.Join(builderx.FieldNames(&User{}), ",")
var userBuilderQueryRows = strings.Join(builder.FieldNames(&User{}), ",")
type User struct {
Avatar string `db:"avatar"` // 头像

View File

@ -78,7 +78,7 @@ sidebar_position: 0
* 安装 goctl 工具
```shell
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
* 创建工作目录 `shorturl``shorturl/api`
@ -97,7 +97,7 @@ sidebar_position: 0
require (
github.com/golang/mock v1.4.3
github.com/golang/protobuf v1.4.2
github.com/tal-tech/go-zero v1.1.4
github.com/zeromicro/go-zero v1.3.0
golang.org/x/net v0.0.0-20200707034311-ab3426394381
google.golang.org/grpc v1.29.1
)
@ -522,13 +522,13 @@ sidebar_position: 0
至此代码修改完成,凡是手动修改的代码我加了标注
**注意:**
1. undefined cache你需要 `import "github.com/tal-tech/go-zero/core/stores/cache"`
1. undefined cache你需要 `import "github.com/zeromicro/go-zero/core/stores/cache"`
2. undefined model, sqlx, hash 等,你需要在文件中
```golang
import "shorturl/rpc/transform/model"
import "github.com/tal-tech/go-zero/core/stores/sqlx"
import "github.com/zeromicro/go-zero/core/stores/sqlx"
```
## 完整调用演示

View File

@ -20,7 +20,7 @@ import (
"syscall"
"time"
"github.com/tal-tech/go-zero/core/fx"
"github.com/zeromicro/go-zero/core/fx"
)
func main() {

View File

@ -65,8 +65,8 @@ import (
"example/zrpc/pb"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
@ -109,8 +109,8 @@ import (
"example/zrpc/pb"
"github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/core/discov"
"github.com/zeromicro/go-zero/zrpc"
)
func main() {

View File

@ -23,4 +23,4 @@ He is also a lecturer at Tencent Cloud Developer Conference.
We currently have more than 7000 community members, where you can discuss any technology about go-zero with everyone, feedback on issues, get the latest go-zero information, and technical insights shared by all the big guys every day.
## go-zero Community Groups
<img src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/wechat.jpg" width="300" alt="Community Groups"/>
<img src="https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/wechat.jpg" width="300" alt="Community Groups"/>

View File

@ -77,9 +77,9 @@ If you think it's good, don't forget to **star** 👏
#### For the full example, please see
[Quick Build Highly Concurrent Microservices](https://github.com/tal-tech/zero-doc/blob/main/doc/shorturl.md)
[Quick Build Highly Concurrent Microservices](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl.md)
[Quick Build Highly Concurrent Microservices - Multi RPC Edition](https://github.com/tal-tech/zero-doc/blob/main/docs/zero/bookstore.md)
[Quick Build Highly Concurrent Microservices - Multi RPC Edition](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/bookstore.md)
#### Install the `goctl` tool
@ -87,13 +87,13 @@ If you think it's good, don't forget to **star** 👏
to free our hands 👈
```shell
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro/go-zero/tools/goctl
```
If you are using go1.16, you can install it with the `go install` command
```shell
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
```
Ensure that `goctl` is executable
@ -146,8 +146,8 @@ goctl api dart -api greet.api -dir greet
[The test code is available here](https://github.com/smallnest/go-web-framework-benchmark)
* awesome series (more articles in 『microservices practice』public)
* [Quickly Building Highly Concurrent Microservices](https://github.com/tal-tech/zero-doc/blob/main/doc/shorturl.md)
* [Quickly Building Highly Concurrent Microservices - Multi RPC Edition](https://github.com/tal-tech/zero-doc/blob/main/docs/zero/bookstore.md)
* [Quickly Building Highly Concurrent Microservices](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl.md)
* [Quickly Building Highly Concurrent Microservices - Multi RPC Edition](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/bookstore.md)
* Featured `goctl` plugin
@ -184,4 +184,4 @@ In order to prevent advertising users, identify technical peers, please ***star*
Before adding me, please click ***star***, a small ***star*** is the motivation for the authors to answer a lot of questions 🤝
<img src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/wechat.jpg" alt="wechat" width="300" />
<img src="https://raw.githubusercontent.com/zeromicro/zero-doc/main/doc/images/wechat.jpg" alt="wechat" width="300" />

View File

@ -133,7 +133,7 @@ Here is a description of how the consumer side of the framework to ensure the un
There are cluster and node. cluster.
`https://github.com/tal-tech/go-queue/blob/master/dq/consumer.go#L45`
`https://github.com/zeromicro/go-queue/blob/master/dq/consumer.go#L45`
- The cluster internally repackages the consume handler with a layer
- hash the consume body and use this hash as the key for redis de-duplication
@ -141,7 +141,7 @@ There are cluster and node. cluster.
#### node
`https://github.com/tal-tech/go-queue/blob/master/dq/consumernode.go#L36`
`https://github.com/zeromicro/go-queue/blob/master/dq/consumernode.go#L36`
- consume node to get ready job; first execute Reserve(TTR), book this job, will execute this job for logical processing
- delete(job) in the node; then consume

View File

@ -254,8 +254,8 @@ import (
"log"
"time"
"github.com/tal-tech/go-zero/core/mr"
"github.com/tal-tech/go-zero/core/timex"
"github.com/zeromicro/go-zero/core/mr"
"github.com/zeromicro/go-zero/core/timex"
)
type user struct{}

View File

@ -260,7 +260,7 @@ $ vim service/user/cmd/api/internal/config/config.go
```go
package config
import "github.com/tal-tech/go-zero/rest"
import "github.com/zeromicro/go-zero/rest"
type Config struct {
rest.RestConf

View File

@ -103,10 +103,10 @@ Here we highly recommend you to install it, because most of our subsequent demo
* download&install
```shell
# Go 1.15 and earlier
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 and later
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
```
* Environment variable detection
@ -183,4 +183,4 @@ We have already prepared Go environment, Go Module configuration, Goctl, protoc
* [etcd](https://etcd.io/docs/current/rfc/v3api/)
* [redis](https://redis.io/)
* [mysql](https://www.mysql.com/)
* [mysql](https://www.mysql.com/)

View File

@ -76,7 +76,7 @@ import (
"go-zero-demo/mall/user/rpc/internal/svc"
"go-zero-demo/mall/user/rpc/user"
"github.com/tal-tech/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserLogic struct {
@ -111,7 +111,7 @@ $ vim internal/config/config.go
package config
import (
"github.com/tal-tech/go-zero/zrpc"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {