Giter Club home page Giter Club logo

snow's Introduction

Language GoDoc Go Report Card

Snow

Snow是一套简单易用的Go语言业务框架,整体逻辑设计简洁,支持HTTP服务、队列调度、任务调度和和脚本任务等常用业务场景模式。

Goals

我们致力于让PHPer更方便地切入到Go语言开发,在业务框架选择上贴合PHP主流框架的设计**,以更低的学习成本快速熟悉框架,致力于业务逻辑的开发。

Features

  • HTTP服务:基于gin进行模块化设计,简单易用、核心足够轻量;支持平滑重启;
  • 任务调度:基于cron进行模块化设计,简单易用;
  • 队列调度:基于自研的高性能队列调度服务worker,通用的Queue接口化,解耦队列调度与底层队列驱动;支持平滑关闭;
  • Cache: 通用的缓存接口化设计,核心组件实现了插件式的redis驱动支持,可扩展;
  • Database: 使用成熟的ORM库,有丰富的数据库驱动支持和特性;
  • Queue: 通用的接口化设计,框架实现了redis、alimns作为队列底层驱动,支持可扩展;
  • Config: 采用toml语义化的配置文件格式,简单易用;
  • Logger: 基于logrus进行封装,内嵌上下文通用数据采集和trace_id追踪;
  • Request and Response:定义输入和输出数据实体格式;
  • Curl: 简单易用的Curl请求库;
  • 脚手架:方便快捷的创建新项目,可一键升级;

Quick start

Requirements

  • Go version >= 1.12
  • Global environment configure (Linux/Mac)
export GO111MODULE=on
export GOPROXY=https://goproxy.io

Installation

go get github.com/qit-team/snow/tool/snow
cd $GOPATH/src
snow new snow-demo

Build & Run

cd snow-demo
go mod vendor
sh build/shell/build.sh
build/bin/snow

Test demo

curl "http://127.0.0.1:8080/hello"

Documents

Contributors

snow's People

Contributors

acoderhit avatar hetiansu5 avatar liuxp0827 avatar sinkcup avatar xiongwilee avatar yukunwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snow's Issues

Go 1.14.2 macOS Catalina下面go get执行报错

~ go get github.com/qit-team/snow/tool/snow

报错如下:

# github.com/qit-team/snow/tool/snow
go/src/github.com/qit-team/snow/tool/snow/main.go:14:15: cannot use []cli.Command literal (type []cli.Command) as type []*cli.Command in assignment
go/src/github.com/qit-team/snow/tool/snow/main.go:20:19: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/qit-team/snow/tool/snow/main.go:26:19: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/qit-team/snow/tool/snow/main.go:39:19: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/qit-team/snow/tool/snow/main.go:45:19: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/qit-team/snow/tool/snow/main.go:51:19: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/qit-team/snow/tool/snow/main.go:57:19: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/qit-team/snow/tool/snow/main.go:63:19: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/qit-team/snow/tool/snow/main.go:92:19: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/qit-team/snow/tool/snow/model.go:86:8: invalid argument ctx.Args() (type cli.Args) for len
go/src/github.com/qit-team/snow/tool/snow/model.go:86:8: too many errors

sed:无法读取 s|github.com/qit-team/snow|my-github/my-space/my-project|:没有那个文件或目录

@hetiansu5

cd $GOPATH/src
# 进入新项目的仓库地址+空间目录
cd my-github/my-space
# 下载源码包,保存为新项目名
git clone [email protected]:qit-team/snow.git my-project
# 进入项目根目录
cd my-project
# 替换为新项目的包命名空间
sh build/shell/replace.sh my-github/my-space/my-project
# 复制样例环境配置为当前环境配置
cp .env.example .env

当走到 sh build/shell/replace.sh my-github/my-space/my-project 这一步的时候, 会报如下错误!!

sed:无法读取 s|github.com/qit-team/snow|my-github/my-space/my-project|:没有那个文件或目录

从如上理解:sed是替换的意思,大致是将github.com/qit-team/snow替换成my-github/my-space/my-project

先抛开问题,咱们看一下build/shell/replace.sh这个文件。

#/bin/bash
# 将项目的包命名空间统一替换成目标目录空间
target=$1
default="github.com/qit-team/snow"
if [ "$target" == "" ]; then
    target="$default"
fi

#回到根目录
rootPath=$(cd `dirname $0`/../../; pwd)

#替换
find . -type f -name "*.*" ! -path "./vendor/*" ! -path "./logs/*" ! -path "./docs/*"  ! -path "./.git/*" ! -path "./build/shell/replace.sh" | xargs sed -i "" "s|${default}|${target}|"

从上面的文件我们能得出几点

  1. rootPath应该是没用吧?
  2. 先查满足规则的文件名(排除几个目录)
  3. 替换sed命令,我是centos,用s|old|new| 应该是不对吧?你的是mac?

====

总之在当走到 sh build/shell/replace.sh my-github/my-space/my-project 这一步的时候, 会报如下错误!!还请抽空帮看下,感谢!!

8000 端口无法访问

go/src/snow-demo$ ./build/bin/snow
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /hello                    --> snow-demo/app/http/controllers.HandleHello (7 handlers)
[GIN-debug] POST   /test                     --> snow-demo/app/http/controllers.HandleTest (7 handlers)
curl "http://127.0.0.1:8000/hello"
curl: (7) Failed to connect to 127.0.0.1 port 8000: Connection refused
curl "http://127.0.0.1:8080/hello"
{"code":200,"data":"hello world!","message":"ok","request_uri":"/hello"}

搜了下代码,7月3号在用8000,9月8号在用8080,打算用哪个呢?gin官方是用8080,既然是基于gin的,建议保持一致。

image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.