Skip to content

Commit

Permalink
feat: rename project from snake to eagle
Browse files Browse the repository at this point in the history
  • Loading branch information
quanlong committed Aug 20, 2021
1 parent f750d18 commit 689e007
Show file tree
Hide file tree
Showing 138 changed files with 490 additions and 469 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 42,5 @@ bin/
vendor

# custom
snake
cmd/eagle
config/config.yaml
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 117,7 @@ linters-settings:
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/1024casts/snake
local-prefixes: github.com/go-eagle/eagle
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
Expand Down
8 changes: 4 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
# see: https://goreleaser.com/customization/

project_name: snake
project_name: eagle

env:
- GO111MODULE=on
Expand All @@ -11,7 11,7 @@ before:

builds:
- main: ./mian.go
binary: snake
binary: eagle
ldflags: -s -w -X main.Version={{.Version}} -X main.BuildDate={{.Date}} -X main.commit={{.Commit}}
goos:
- linux
Expand All @@ -36,7 36,7 @@ changelog:
- Merge branch

archives:
- id: snake
- id: eagle
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
format: tar.gz
format_overrides:
Expand All @@ -50,5 50,5 @@ archives:
release:
github:
owner: qloog
name: snake
name: eagle
name_template: '{{.Tag}}'
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@
- 优化 add trace for http client and sql

## v1.3.1
- 优化 新建项目命令 `snake new`
- 优化 新建项目命令 `eagle new`
- 优化 目录结构
- 新增 链路追踪 tracing 支持 jaeger、zipkin、elastic
- 新增 SQL库,支持 tracing
Expand All @@ -28,7 28,7 @@
- 优化 graceful stop 方法
- 优化 token sign 方法支持自定义参数payload
- 优化 redis lock, 将token收敛到包内进行处理,减少使用的心智负担
- 优化 创建项目命令 `snake new`
- 优化 创建项目命令 `eagle new`
- 优化 移除cache prefix, 由用户自己定义
- 优化 数据获取,使用 singleflight,防止缓存击穿
- 优化 数据为空时缓存一分钟,防止缓存穿透
Expand All @@ -43,7 43,7 @@
## v1.2.1
- 新增 增加job目录,可以在 `cmd/job` 中定义具体任务
- 优化 http client, 支持原生(raw)包方式请求和第三方库resty
- 优化 snake new 命令,使用新的 main.go 文件
- 优化 eagle new 命令,使用新的 main.go 文件
- 优化 `service``repository` 公共方法增加首个参数 `ctx Context.context`
- 优化 修改目录 `pkg/util``pkg/utils`

Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 16,7 @@ ENV GO111MODULE=on \
TZ=Asia/Shanghai

# 移动到工作目录
WORKDIR /go/src/github.com/1024casts/snake
WORKDIR /go/src/github.com/go-eagle/eagle

# 复制项目中的 go.mod 和 go.sum文件并下载依赖信息
COPY go.mod .
Expand All @@ -37,18 37,18 @@ FROM debian:stretch-slim
WORKDIR /app

# 从builder镜像中把 /build 拷贝到当前目录
COPY --from=builder /go/src/github.com/1024casts/snake/snake /app/snake
COPY --from=builder /go/src/github.com/1024casts/snake/config /app/config
COPY --from=builder /go/src/github.com/go-eagle/eagle/eagle /app/eagle
COPY --from=builder /go/src/github.com/go-eagle/eagle/config /app/config

RUN mkdir -p /data/logs/

# Expose port 8080 to the outside world
EXPOSE 8080

# 需要运行的命令
CMD ["/app/snake", "-c", "config/config.docker.yaml"]
CMD ["/app/eagle", "-c", "config/config.docker.yaml"]

# 1. build image: docker build -t snake:v1 -f Dockerfile .
# 2. start: docker run --rm -it -p 8080:8080 snake:v1
# 1. build image: docker build -t eagle:v1 -f Dockerfile .
# 2. start: docker run --rm -it -p 8080:8080 eagle:v1
# 3. test: curl -i http://localhost:8080/health

10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 2,15 @@ SHELL := /bin/bash
BASEDIR = $(shell pwd)

# build with version infos
versionDir = "github.com/1024casts/snake/pkg/version"
versionDir = "github.com/go-eagle/eagle/pkg/version"
gitTag = $(shell if [ "`git describe --tags --abbrev=0 2>/dev/null`" != "" ];then git describe --tags --abbrev=0; else git log --pretty=format:'%h' -n 1; fi)
buildDate = $(shell TZ=Asia/Shanghai date %FT%T%z)
gitCommit = $(shell git log --pretty=format:'%H' -n 1)
gitTreeState = $(shell if git status|grep -q 'clean';then echo clean; else echo dirty; fi)

ldflags="-w -X ${versionDir}.gitTag=${gitTag} -X ${versionDir}.buildDate=${buildDate} -X ${versionDir}.gitCommit=${gitCommit} -X ${versionDir}.gitTreeState=${gitTreeState}"

PROJECT_NAME := "github.com/1024casts/snake"
PROJECT_NAME := "github.com/go-eagle/eagle"
PKG := "$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
Expand Down Expand Up @@ -85,12 85,12 @@ gen-coverage:
.PHONY: docker
# make docker 生成docker镜像
docker:
docker build -t snake:$(versionDir) -f Dockeffile .
docker build -t eagle:$(versionDir) -f Dockeffile .

.PHONY: clean
# make clean
clean:
@-rm -vrf snake
@-rm -vrf eagle
@-rm -vrf cover.out
@-rm -vrf coverage.txt
@go mod tidy
Expand Down Expand Up @@ -119,7 119,7 @@ graph:
go get -u github.com/ofabry/go-callvis; \
fi
@echo "generating graph"
@go-callvis github.com/1024casts/snake
@go-callvis github.com/go-eagle/eagle

.PHONY: mockgen
# make mockgen gen mock file
Expand Down
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 1,13 @@
# 🐍 snake
# 🦅 eagle

[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/1024casts/snake/Go?style=flat-square)](https://github.com/1024casts/snake)
[![codecov](https://codecov.io/gh/1024casts/snake/branch/master/graph/badge.svg)](https://codecov.io/gh/1024casts/snake)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/go-eagle/eagle/Go?style=flat-square)](https://github.com/go-eagle/eagle)
[![codecov](https://codecov.io/gh/go-eagle/eagle/branch/master/graph/badge.svg)](https://codecov.io/gh/go-eagle/eagle)
[![GolangCI](https://golangci.com/badges/github.com/golangci/golangci-lint.svg)](https://golangci.com)
[![godoc](https://godoc.org/github.com/1024casts/snake?status.svg)](https://godoc.org/github.com/1024casts/snake)
[![godoc](https://godoc.org/github.com/go-eagle/eagle?status.svg)](https://godoc.org/github.com/go-eagle/eagle)
<a href="http://opentracing.io"><img src="https://img.shields.io/badge/OpenTracing-enabled-blue.svg" alt="OpenTracing Badge"></a>
[![Go Report Card](https://goreportcard.com/badge/github.com/1024casts/snake)](https://goreportcard.com/report/github.com/1024casts/snake)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-eagle/eagle)](https://goreportcard.com/report/github.com/go-eagle/eagle)
[![gitmoji](https://img.shields.io/badge/gitmoji- 😜 😍-FFDD67.svg?style=flat-square)](https://github.com/carloscuesta/gitmoji)
[![License](https://img.shields.io/github/license/1024casts/snake?style=flat-square)](/LICENSE)
[![License](https://img.shields.io/github/license/go-eagle/eagle?style=flat-square)](/LICENSE)

一款适合于快速开发业务的 Go 框架,可快速构建 API 服务 或 Web 网站。

Expand Down Expand Up @@ -78,10 78,10 @@ TIPS: 需要本地安装MySQL数据库和 Redis

```bash
# 下载安装,可以不用是 GOPATH
git clone https://github.com/1024casts/snake
git clone https://github.com/go-eagle/eagle

# 进入到下载目录
cd snake
cd eagle

# 生成环境配置文件
cd config
Expand All @@ -100,16 100,16 @@ make build

```bash
# 下载
go get github.com/1024casts/snake/cmd/snake
go get github.com/go-eagle/eagle/cmd/eagle

export GO111MODULE=on
# 或者在.bashrc 或 .zshrc中加入
# source .bashrc 或 source .zshrc

# 使用
snake new snake-demo
eagle new eagle-demo
# 或者
snake new github.com/foo/bar
eagle new github.com/foo/bar
```

## 💻 常用命令
Expand Down Expand Up @@ -148,11 148,11 @@ snake new github.com/foo/bar

## 📖 开发规约

- [配置说明](https://github.com/1024casts/snake/blob/master/conf)
- [错误码设计](https://github.com/1024casts/snake/tree/master/pkg/errno)
- [service 的使用规则](https://github.com/1024casts/snake/blob/master/internal/service)
- [repository 的使用规则](https://github.com/1024casts/snake/blob/master/internal/repository)
- [cache 使用说明](https://github.com/1024casts/snake/blob/master/pkg/cache)
- [配置说明](https://github.com/go-eagle/eagle/blob/master/conf)
- [错误码设计](https://github.com/go-eagle/eagle/tree/master/pkg/errno)
- [service 的使用规则](https://github.com/go-eagle/eagle/blob/master/internal/service)
- [repository 的使用规则](https://github.com/go-eagle/eagle/blob/master/internal/repository)
- [cache 使用说明](https://github.com/go-eagle/eagle/blob/master/pkg/cache)

## 🚀 部署

Expand Down Expand Up @@ -181,7 181,7 @@ http://127.0.0.1/health
编译并生成二进制文件

```bash
go build -o bin_snake
go build -o bin_eagle
```

如果应用有多台机器,可以在编译机器进行编译,然后使用rsync同步到对应的业务应用服务器
Expand All @@ -192,42 192,42 @@ go build -o bin_snake
export GOROOT=/usr/local/go1.13.8
export GOPATH=/data/build/test/src
export GO111MODULE=on
cd /data/build/test/src/github.com/1024casts/snake
/usr/local/go1.13.8/bin/go build -o /data/build/bin/bin_snake -mod vendor main.go
rsync -av /data/build/bin/ x.x.x.x:/home/go/snake
supervisorctl restart snake
cd /data/build/test/src/github.com/go-eagle/eagle
/usr/local/go1.13.8/bin/go build -o /data/build/bin/bin_eagle -mod vendor main.go
rsync -av /data/build/bin/ x.x.x.x:/home/go/eagle
supervisorctl restart eagle
```

这里日志目录设定为 `/data/log`
如果安装了 Supervisord,可以在配置文件中添加下面内容(默认:`/etc/supervisor/supervisord.conf`):

```ini
[program:snake]
[program:eagle]
# environment=
directory=/home/go/snake
command=/home/go/snake/bin_snake
directory=/home/go/eagle
command=/home/go/eagle/bin_eagle
autostart=true
autorestart=true
user=root
stdout_logfile=/data/log/snake_std.log
stdout_logfile=/data/log/eagle_std.log
startsecs = 2
startretries = 2
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=10
stderr_logfile=/data/log/snake_err.log
stderr_logfile=/data/log/eagle_err.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=10
```

重启 Supervisord

```bash
supervisorctl restart snake
supervisorctl restart eagle
```

## 📜 CHANGELOG

- [更新日志](https://github.com/1024casts/snake/blob/master/CHANGELOG.md)
- [更新日志](https://github.com/go-eagle/eagle/blob/master/CHANGELOG.md)

## 🏘️ 谁在用

Expand All @@ -236,18 236,18 @@ supervisorctl restart snake

## 💬 Discussion

- Issue: https://github.com/1024casts/snake/issues
- Issue: https://github.com/go-eagle/eagle/issues
- QQ交流群:1074476202

## Stargazers over time

[![Stargazers over time](https://starchart.cc/1024casts/snake.svg)](https://starchart.cc/1024casts/snake)
[![Stargazers over time](https://starchart.cc/go-eagle/eagle.svg)](https://starchart.cc/go-eagle/eagle)

## 🔋 JetBrains 开源证书支持

`snake` 项目一直以来都是在 JetBrains 公司旗下的 GoLand 集成开发环境中进行开发,基于 **free JetBrains Open Source license(s)** 正版免费授权,在此表达我的谢意。
`eagle` 项目一直以来都是在 JetBrains 公司旗下的 GoLand 集成开发环境中进行开发,基于 **free JetBrains Open Source license(s)** 正版免费授权,在此表达我的谢意。

<a href="https://www.jetbrains.com/?from=1024casts/snake" target="_blank"><img src="https://raw.githubusercontent.com/panjf2000/illustrations/master/jetbrains/jetbrains-variant-4.png" width="200" align="middle"/></a>
<a href="https://www.jetbrains.com/?from=go-eagle/eagle" target="_blank"><img src="https://raw.githubusercontent.com/panjf2000/illustrations/master/jetbrains/jetbrains-variant-4.png" width="200" align="middle"/></a>

## 📄 License

Expand Down
6 changes: 3 additions & 3 deletions api/grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 128,14 @@ find rpc -name '*.proto' -exec protoc --twirp_out=. --go_out=. {} \;

## 实现接口

请参考 [server/README.md](https://github.com/1024casts/snake/tree/master/internal/server/README.md)
请参考 [server/README.md](https://github.com/go-eagle/eagle/tree/master/internal/server/README.md)

## 自动注册

snake 提供的脚手架可以自动生成 proto 模版、server 模版,并注册路由。 运行以下命令:
eagle 提供的脚手架可以自动生成 proto 模版、server 模版,并注册路由。 运行以下命令:

```bash
go run cmd/snake/main.go rpc --server=foo --service=echo
go run cmd/eagle/main.go rpc --server=foo --service=echo
```

会自动生成
Expand Down
4 changes: 2 additions & 2 deletions api/grpc/user/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 7,8 @@ import (

"google.golang.org/grpc"

"github.com/1024casts/snake/api/grpc/user/v1"
"github.com/1024casts/snake/pkg/log"
"github.com/go-eagle/eagle/api/grpc/user/v1"
"github.com/go-eagle/eagle/pkg/log"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions api/http/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 487,8 @@ var SwaggerInfo = swaggerInfo{
Host: "localhost:8080",
BasePath: "/v1",
Schemes: []string{},
Title: "snake docs api",
Description: "snake demo",
Title: "eagle docs api",
Description: "eagle demo",
}

type s struct{}
Expand Down
4 changes: 2 additions & 2 deletions api/http/swagger.json
Original file line number Diff line number Diff line change
@@ -1,8 1,8 @@
{
"swagger": "2.0",
"info": {
"description": "snake demo",
"title": "snake docs api",
"description": "eagle demo",
"title": "eagle docs api",
"contact": {},
"version": "1.0"
},
Expand Down
4 changes: 2 additions & 2 deletions api/http/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 95,8 @@ definitions:
host: localhost:8080
info:
contact: {}
description: snake demo
title: snake docs api
description: eagle demo
title: eagle docs api
version: "1.0"
paths:
/Register:
Expand Down
4 changes: 2 additions & 2 deletions api/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 5,8 @@ import (

"github.com/gin-gonic/gin"

"github.com/1024casts/snake/pkg/errcode"
"github.com/1024casts/snake/pkg/utils"
"github.com/go-eagle/eagle/pkg/errcode"
"github.com/go-eagle/eagle/pkg/utils"
)

// Response api的返回结构体
Expand Down
Loading

0 comments on commit 689e007

Please sign in to comment.