diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..081b737
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 数据源本地存储已忽略文件
+/dataSources/
+/dataSources.local.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
diff --git a/.idea/ArmedPolice.iml b/.idea/ArmedPolice.iml
new file mode 100644
index 0000000..5e764c4
--- /dev/null
+++ b/.idea/ArmedPolice.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..cba44df
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/event/redis.go b/app/event/redis.go
new file mode 100644
index 0000000..331d5d7
--- /dev/null
+++ b/app/event/redis.go
@@ -0,0 +1,56 @@
+package event
+
+import (
+ "ArmedPolice/serve/cache"
+ "fmt"
+)
+
+type (
+ RedisHashProduce struct{}
+
+ RedisHashDestroy struct{}
+)
+
+type (
+ RedisListProduce struct{}
+
+ RedisListDestroy struct{}
+)
+
+func (this *RedisHashProduce) Handle(args ...interface{}) {
+ _ = cache.Cache.HSet(args[0].(string), args[1].(string), args[2])
+}
+
+func NewRedisHashProduce() *RedisHashProduce {
+ return &RedisHashProduce{}
+}
+
+func (this *RedisHashDestroy) Handle(args ...interface{}) {
+ fields := make([]string, 0)
+
+ for i := 1; i < len(args); i++ {
+ fields = append(fields, args[i].(string))
+ }
+ _ = cache.Cache.HDel(args[0].(string), fields...)
+}
+
+func NewRedisHashDestroy() *RedisHashDestroy {
+ return &RedisHashDestroy{}
+}
+
+func (this *RedisListProduce) Handle(args ...interface{}) {
+ _ = cache.Cache.SAdd(args[0].(string), args[1:]...)
+}
+
+func NewRedisListProduce() *RedisListProduce {
+ return &RedisListProduce{}
+}
+
+func (this *RedisListDestroy) Handle(args ...interface{}) {
+ err := cache.Cache.SRem(args[0].(string), args[1:]...)
+ fmt.Println(err)
+}
+
+func NewRedisListDestroy() *RedisListDestroy {
+ return &RedisListDestroy{}
+}
diff --git a/app/init.go b/app/init.go
new file mode 100644
index 0000000..21f1ce4
--- /dev/null
+++ b/app/init.go
@@ -0,0 +1,16 @@
+package app
+
+import (
+ "Edu/app/event"
+ "Edu/app/service"
+ "Edu/config"
+)
+
+func Init() {
+ // RedisHash存储/移除监听
+ service.Subscribe(config.EventForRedisHashProduce, event.NewRedisHashProduce())
+ service.Subscribe(config.EventForRedisHashDestroy, event.NewRedisHashDestroy())
+ // RedisList存储/移除监听
+ service.Subscribe(config.EventForRedisListProduce, event.NewRedisListProduce())
+ service.Subscribe(config.EventForRedisListDestroy, event.NewRedisListDestroy())
+}
diff --git a/app/service/captcha.go b/app/service/captcha.go
new file mode 100644
index 0000000..09e06f6
--- /dev/null
+++ b/app/service/captcha.go
@@ -0,0 +1,106 @@
+package service
+
+import (
+ "errors"
+
+ "github.com/mojocn/base64Captcha"
+)
+
+type Param struct {
+ obj interface{}
+}
+
+type CaptchaInfo struct {
+ Key string `json:"key"`
+ Captcha string `json:"captcha"`
+}
+
+type CaptchaType string
+
+const (
+ CaptchaTypeForDefault CaptchaType = "default"
+ CaptchaTypeForAudio CaptchaType = "audio"
+ CaptchaTypeForString CaptchaType = "string"
+ CaptchaTypeForMath CaptchaType = "math"
+ CaptchaTypeForChinese CaptchaType = "chinese"
+)
+
+var drivers = map[CaptchaType]func() base64Captcha.Driver{
+ CaptchaTypeForDefault: captchaForDigit,
+ CaptchaTypeForAudio: captchaForAudio,
+ CaptchaTypeForString: captchaForString,
+ CaptchaTypeForMath: captchaForMath,
+ CaptchaTypeForChinese: captchaForChinese,
+}
+
+var store = base64Captcha.DefaultMemStore
+
+func captchaForDigit() base64Captcha.Driver {
+ drive := new(base64Captcha.DriverDigit)
+ drive.Width = 100
+ drive.Height = 40
+ drive.DotCount = 80
+ drive.Length = 6
+ drive.MaxSkew = 0.7
+ return drive
+}
+
+func captchaForAudio() base64Captcha.Driver {
+ drive := new(base64Captcha.DriverAudio)
+ drive.Language = "zh"
+ drive.Length = 4
+ return drive
+}
+
+func captchaForString() base64Captcha.Driver {
+ drive := new(base64Captcha.DriverString)
+ drive.Width = 100
+ drive.Width = 40
+ drive.Source = "设想,你在,处理,消费者,的音,频输,出音,频可,能无,论什,么都,没有,任何,输出,或者,它可,能是,单声道,立体声,或是,环绕立,体声的,不想要,的值"
+ drive.Length = 2
+ return drive.ConvertFonts()
+}
+
+func captchaForMath() base64Captcha.Driver {
+ drive := new(base64Captcha.DriverMath)
+ drive.Width = 100
+ drive.Height = 40
+ drive.NoiseCount = 1
+ return drive.ConvertFonts()
+}
+
+func captchaForChinese() base64Captcha.Driver {
+ drive := new(base64Captcha.DriverChinese)
+ drive.Width = 100
+ drive.Width = 40
+ drive.Source = "1234567890qwertyuioplkjhgfdsazxcvbnm"
+ drive.Length = 4
+ return drive.ConvertFonts()
+}
+
+func (this *Param) Create() (*CaptchaInfo, error) {
+ obj := this.obj.(CaptchaType)
+
+ drive, has := drivers[obj]
+
+ if !has {
+ return nil, errors.New("参数异常")
+ }
+ c := base64Captcha.NewCaptcha(drive(), store)
+
+ key, captcha, err := c.Generate()
+
+ if err != nil {
+ return nil, err
+ }
+ return &CaptchaInfo{Key: key, Captcha: captcha}, nil
+}
+
+func (this *Param) Validate() bool {
+ obj := this.obj.(*CaptchaInfo)
+ return store.Verify(obj.Key, obj.Captcha, true)
+}
+
+func Captcha(obj interface{}) *Param {
+ return &Param{obj: obj}
+}
diff --git a/app/service/eventhub.go b/app/service/eventhub.go
new file mode 100644
index 0000000..b0f6cb4
--- /dev/null
+++ b/app/service/eventhub.go
@@ -0,0 +1,56 @@
+package service
+
+import (
+ "sync"
+)
+
+// listener 监听
+type listener struct {
+ handler ListenerHandle
+}
+
+// listeners 监听器
+type listeners struct {
+ listener map[interface{}]*listener
+ mutex *sync.RWMutex
+}
+
+// ListenerHandle 监听事件
+type ListenerHandle interface {
+ Handle(args ...interface{})
+}
+
+// listenerObject 监听器
+var listenerObject = &listeners{
+ listener: make(map[interface{}]*listener, 0),
+ mutex: new(sync.RWMutex),
+}
+
+// Subscribe 注册事件
+func Subscribe(prefix interface{}, handler ListenerHandle) {
+ listenerObject.mutex.Lock()
+ defer listenerObject.mutex.Unlock()
+ listenerObject.listener[prefix] = &listener{handler: handler}
+}
+
+// Publish 推送事件
+func Publish(prefix interface{}, args ...interface{}) {
+ listenerObject.mutex.RLock()
+ defer listenerObject.mutex.RUnlock()
+ listener, has := listenerObject.listener[prefix]
+ if !has {
+ return
+ }
+ listener.handler.Handle(args...)
+}
+
+// Unsubscribe 取消监听
+func Unsubscribe(prefix interface{}) {
+ listenerObject.mutex.Lock()
+ defer listenerObject.mutex.Unlock()
+ _, has := listenerObject.listener[prefix]
+ if !has {
+ return
+ }
+ delete(listenerObject.listener, prefix)
+}
diff --git a/app/service/session.go b/app/service/session.go
new file mode 100644
index 0000000..85cc759
--- /dev/null
+++ b/app/service/session.go
@@ -0,0 +1,30 @@
+package service
+
+import (
+ "Edu/utils"
+ "encoding/json"
+)
+
+type Session struct {
+ ID uint64 `json:"id"` // 用户ID
+ OpenID string `json:"open_id"`
+ Token string `json:"token"` // token
+ Name string `json:"name"` // 名称
+ SessionKey string `json:"session_key"` // 用户信息
+}
+
+func (this *Session) MarshalBinary() ([]byte, error) {
+ return json.Marshal(this)
+}
+
+func (this *Session) UnmarshalBinary(data []byte) error {
+ return utils.FromJSONBytes(data, this)
+}
+
+func (this *Session) IDToString() string {
+ return utils.UintToString(this.ID)
+}
+
+func NewSession() *Session {
+ return &Session{}
+}
diff --git a/build_linux.sh b/build_linux.sh
new file mode 100755
index 0000000..fa32073
--- /dev/null
+++ b/build_linux.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+set -e
+
+CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags release -ldflags "-X 'main.buildDateTime=$(date '+%Y-%m-%d %H:%M:%S')' -X 'main.gitCommitCode=$(git rev-list --full-history --all --abbrev-commit --max-count 1)' -s -w" -o Edu main.go
\ No newline at end of file
diff --git a/cmd/ctl/README.md b/cmd/ctl/README.md
new file mode 100644
index 0000000..e1a6435
--- /dev/null
+++ b/cmd/ctl/README.md
@@ -0,0 +1,3 @@
+## Init
+
+go build ./cmd/ctl
\ No newline at end of file
diff --git a/cmd/ctl/command/model/file.go b/cmd/ctl/command/model/file.go
new file mode 100644
index 0000000..7b1a265
--- /dev/null
+++ b/cmd/ctl/command/model/file.go
@@ -0,0 +1,62 @@
+package model
+
+import (
+ "ArmedPolice/utils"
+ "bytes"
+ "fmt"
+ "go/format"
+ "text/template"
+)
+
+const ModelTemplate = `package {{.Name}}
+
+type {{.StrutName}} struct {
+ Model
+ ModelDeleted
+ ModelAt
+}
+
+func (m *{{.StrutName}}) TableName() string {
+ return "{{.TableName}}"
+}
+
+func New{{.StrutName}}() *{{.StrutName}} {
+ return &{{.StrutName}}{}
+}`
+
+type ModelFile struct {
+ // Name is the plugin name. Snack style.
+ Name string
+ // StrutName is the struct name.
+ StrutName string
+ // TableName is the model table name.
+ TableName string
+}
+
+func (v *ModelFile) Execute(file, tmplName, tmpl string) error {
+ fmt.Println(file)
+ f, err := utils.Open(file)
+
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ temp := new(template.Template)
+
+ if temp, err = template.New(tmplName).Parse(tmpl); err != nil {
+ return err
+ }
+ buf := new(bytes.Buffer)
+
+ if err = temp.Execute(buf, v); err != nil {
+ return err
+ }
+ out := make([]byte, 0)
+
+ if out, err = format.Source(buf.Bytes()); err != nil {
+ return err
+ }
+ _, err = f.Write(out)
+ return err
+}
diff --git a/cmd/ctl/command/model/model.go b/cmd/ctl/command/model/model.go
new file mode 100644
index 0000000..27d5601
--- /dev/null
+++ b/cmd/ctl/command/model/model.go
@@ -0,0 +1,73 @@
+package model
+
+import (
+ "Edu/config"
+ "Edu/serve/logger"
+ "Edu/utils"
+ "fmt"
+ "os"
+ "path"
+ "strings"
+
+ "github.com/spf13/cobra"
+)
+
+// ModelCommand
+var ModelCommand = &cobra.Command{
+ Use: "make:model",
+ Short: "quick make model",
+ Example: "ctl make:model -f sys_user -t sys_user",
+ Version: *config.Version,
+}
+
+var (
+ file string
+ tableName string
+)
+
+func init() {
+ ModelCommand.Flags().StringVarP(&file, "file", "f", "", "The file name.")
+ ModelCommand.Flags().StringVarP(&tableName, "tableName", "t", "", "The file model tableName")
+ ModelCommand.Run = func(cmd *cobra.Command, args []string) {
+ utils.TryCatch(func() {
+ if file == "" {
+ logger.ErrorF("Filename Not Nil")
+ return
+ }
+ if tableName == "" {
+ logger.ErrorF("TableName Not Nil")
+ return
+ }
+ file := strings.ToLower(file)
+
+ dir, err := os.Getwd()
+
+ output := "/app/common/model"
+
+ output = path.Join(dir, output)
+
+ if err != nil {
+ logger.ErrorF("Make Model Error:%v", err)
+ return
+ }
+ if err = utils.PrepareOutput(output); err != nil {
+ logger.ErrorF("Make Model Error:%v", err)
+ return
+ }
+ fmt.Println(output)
+
+ modelFile := &ModelFile{
+ Name: "model",
+ StrutName: utils.ToSnake(file, "_"),
+ TableName: tableName,
+ }
+ err = modelFile.Execute(path.Join(output, file+".go"), "model", ModelTemplate)
+
+ if err != nil {
+ logger.ErrorF("Make Model Error:%v", err)
+ return
+ }
+ return
+ })
+ }
+}
diff --git a/cmd/ctl/main.go b/cmd/ctl/main.go
new file mode 100644
index 0000000..a614d88
--- /dev/null
+++ b/cmd/ctl/main.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "Edu/cmd/ctl/command/model"
+ "Edu/config"
+
+ "github.com/spf13/cobra"
+)
+
+var rootCmd = &cobra.Command{
+ Use: "ctl",
+ Long: "ctl is a command line tool for serve",
+ Version: *config.Version,
+}
+
+func init() {
+ rootCmd.AddCommand(model.ModelCommand)
+}
+
+func main() {
+ _ = rootCmd.Execute()
+}
diff --git a/cmd/serve/serve.go b/cmd/serve/serve.go
new file mode 100644
index 0000000..f1dafd1
--- /dev/null
+++ b/cmd/serve/serve.go
@@ -0,0 +1,56 @@
+package serve
+
+import (
+ "ArmedPolice/app"
+ "ArmedPolice/config"
+ "ArmedPolice/lib"
+ "ArmedPolice/router"
+ "ArmedPolice/serve/cache"
+ "ArmedPolice/serve/logger"
+ "ArmedPolice/serve/orm"
+ "ArmedPolice/serve/web"
+ "ArmedPolice/task"
+ "ArmedPolice/tools"
+ "strings"
+
+ "github.com/gin-gonic/gin"
+)
+
+type Serve struct {
+ *Option
+}
+
+type Option struct {
+ Config string `json:"config"`
+ RpcConfig string `json:"rpc_config"`
+}
+
+func (this *Serve) Run() {
+ // 载入配置
+ lib.LoadConfig(this.Option.Config, config.SettingInfo, func(i interface{}) {
+ obj := i.(*config.Setting)
+ obj.Upload.Exts = strings.Split(obj.Upload.Ext, ",")
+ logger.NewLogger().Init(&logger.Option{File: obj.Log.File, LeastDay: obj.Log.LeastDay, Level: obj.Log.Level, IsStdout: false}).Load()
+ })
+ cache.Init()
+ orm.Init()
+ task.Init()
+ app.Init()
+ tools.Init()
+ // 开启web
+ web.NewWeb()(&web.WebConfig{
+ Port: config.SettingInfo.Server.Port, ReadTimeout: config.SettingInfo.Server.ReadTimeout,
+ WriteTimeout: config.SettingInfo.Server.WriteTimeout, IdleTimeout: config.SettingInfo.Server.IdleTimeout,
+ }).Run(router.NewRouter(&router.Option{
+ Mode: gin.DebugMode, IsCors: true,
+ RateLimitConfig: &router.RateLimitConfig{
+ IsRate: true, Limit: config.SettingInfo.Rate.Limit, Capacity: config.SettingInfo.Rate.Capacity,
+ },
+ }).Init())
+}
+
+func NewServe() func(option *Option) *Serve {
+ return func(option *Option) *Serve {
+ return &Serve{option}
+ }
+}
diff --git a/config.yaml b/config.yaml
new file mode 100644
index 0000000..6d35174
--- /dev/null
+++ b/config.yaml
@@ -0,0 +1,81 @@
+name: 教育
+# domain 域名
+domain: http://192.168.31.195:8030/
+# token有效时间(秒)
+token_effect_time: 2592000
+# multiple_login 多地登录
+multiple_login: true
+
+server:
+ port: 8010
+ read_timeout: 5
+ write_timeout: 5
+ idle_timeout: 5
+
+# config 配置信息
+config:
+ vip_price: 99
+
+ wechat:
+# appid: wxc8b039943eca7a27
+ appid: wx880e43c02bf7bd55
+# appsecret: a96335396caa2e91d9f93c8ba88f83ae
+ appsecret: 10017dff4f55f86cb2074003f38b5a23
+
+# RATE 限流器
+rate:
+ # 每秒注入容器中数量
+ limit: 50
+ # 每个IP每秒请求最大次数
+ capacity: 100
+
+# ENGINE 配置
+engine:
+ # 开启会输出sql日志
+ debug: true
+ # db_mode - mysql | sqlite
+ db_mode: mysql
+ max_lifetime: 3600
+ max_open_conns: 2000
+ max_idle_conns: 1000
+ table_prefix:
+ # 是否采用数据表复数
+ complex: false
+ # MYSQL 配置
+ mysql:
+# host: 47.96.31.6
+ host: 127.0.0.1
+ port: 3306
+ user: appuser
+ password: ABCabc01
+ db_name: edu
+ parameters: charset=utf8mb4,utf8&parseTime=True&loc=Asia%2FShanghai
+ # SQLITE 配置
+ sqlite:
+ path: data
+ name: app.db
+
+cache:
+ # memory | redis
+ type: redis
+ redis:
+ addr: "127.0.0.1:6379"
+ password: ABCabc01
+ db: 4
+ max_active: 0
+ max_idle: 1000
+ idle_timeout: 240
+
+# UPLOAD 上传文件配置
+upload:
+ path: upload/
+ ext: png,jpg,csv,xls,xlsx,pcm,wav,amr,mp3,mp4,json
+ # size 4<<20,不支持位运算,文件最大限制
+ size: 4194304
+ rename: true
+
+#LOG 日志管理
+log:
+ file: log/logs.log
+ least_day: 7
+ level: info # debug | info | warn | error
\ No newline at end of file
diff --git a/config/config.go b/config/config.go
new file mode 100644
index 0000000..d182f5a
--- /dev/null
+++ b/config/config.go
@@ -0,0 +1,115 @@
+package config
+
+var (
+ SettingInfo = new(Setting)
+ RPCServerSettingInfo = new(RPCServerSetting)
+ SettingAreaInfo = make(map[string]map[string]string, 0)
+)
+
+// Mysql 配置
+type Mysql struct {
+ Host string `yaml:"host"`
+ Port int `yaml:"port"`
+ User string `yaml:"user"`
+ Password string `yaml:"password"`
+ DBName string `yaml:"db_name"`
+ Parameters string `yaml:"parameters"`
+}
+
+// Sqlite 配置
+type Sqlite struct {
+ Path string `yaml:"path"`
+ Name string `yaml:"name"`
+}
+
+// RPCServer RPC Server服务
+type RPCServer struct {
+ Host string `yaml:"host"`
+ Port int `yaml:"port"`
+ IsTLS bool `yaml:"is_tls"`
+ TLSName string `yaml:"tls_name"`
+ Pem string `yaml:"pem"`
+ Key string `yaml:"key"`
+}
+
+// Redis 配置
+type Redis struct {
+ Addr string `yaml:"addr"`
+ Password string `yaml:"password"`
+ DB int `yaml:"db"`
+ MaxActive int `yaml:"max_active"`
+ MaxIdle int `yaml:"max_idle"`
+ IdleTimeout int `yaml:"idle_timeout"`
+}
+
+// Setting 配置信息
+type Setting struct {
+ Domain string `json:"domain" yaml:"domain"`
+ Name string `yaml:"name"`
+ TokenEffectTime int `yaml:"token_effect_time"`
+ MultipleLogin bool `yaml:"multiple_login"`
+
+ // Server 配置
+ Server struct {
+ Port int `yaml:"port"`
+ ReadTimeout int `yaml:"read_timeout"`
+ WriteTimeout int `yaml:"write_timeout"`
+ IdleTimeout int `yaml:"idle_timeout"`
+ }
+
+ // Config 配置
+ Config struct {
+ VipPrice float64 `yaml:"vip_price"`
+ Wechat struct {
+ AppID string `json:"appid"`
+ AppSecret string `yaml:"appsecret"`
+ } `yaml:"wechat"`
+ }
+
+ // Rate 限流器
+ Rate struct {
+ Limit int `yaml:"limit"`
+ Capacity int `yaml:"capacity"`
+ }
+
+ // Engine 配置
+ Engine struct {
+ Debug bool `yaml:"debug"`
+ DBMode string `yaml:"db_mode"`
+ MaxLifetime int `yaml:"max_lifetime"`
+ MaxOpenConns int `yaml:"max_open_conns"`
+ MaxIdleConns int `yaml:"max_idle_conns"`
+ TablePrefix string `yaml:"table_prefix"`
+ Complex bool `yaml:"complex"`
+ Mysql *Mysql `yaml:"mysql"`
+ Sqlite *Sqlite `yaml:"sqlite"`
+ }
+
+ // Cache 缓存配置
+ Cache struct {
+ Type string `yaml:"type"`
+ Redis *Redis `yaml:"redis"`
+ }
+
+ // Upload 配置
+ Upload struct {
+ Path string `yaml:"path"`
+ Ext string `yaml:"ext"`
+ Exts []string `yaml:"-"`
+ Size int64 `yaml:"size"`
+ Rename bool `yaml:"rename"`
+ }
+
+ // Log 配置
+ Log struct {
+ File string `yaml:"file"`
+ LeastDay uint `yaml:"least_day"`
+ Level string `yaml:"level"`
+ }
+}
+
+// RPCServerSetting 配置
+type RPCServerSetting struct {
+ Key int `yaml:"key"`
+ Servers map[string]*RPCServer `yaml:"servers"`
+}
diff --git a/config/const.go b/config/const.go
new file mode 100644
index 0000000..8c473a7
--- /dev/null
+++ b/config/const.go
@@ -0,0 +1,42 @@
+package config
+
+// Redis
+
+const (
+ RedisKeyForTaskQueue string = "task_queue"
+ RedisKeyForTaskQueueBody string = "task_queue_body"
+
+ RedisKeyForAccount string = "account"
+ RedisKeyForTenant string = "tenant:instance"
+ RedisKeyForTenantKeys string = "tenant:keys"
+)
+
+const (
+ TokenForUID string = "uid"
+ TokenForSession string = "session"
+ TokenForGrade string = "grade"
+)
+
+const (
+ APIRequestToken string = "x-token"
+ APIRequestGrade string = "x-grade"
+)
+
+const (
+ ContentForLocal string = "local"
+)
+
+const (
+ EventForRedisHashProduce string = "redis_hash_produce"
+ EventForRedisHashDestroy string = "redis_hash_destroy"
+
+ EventForRedisListProduce string = "redis_list_produce"
+ EventForRedisListDestroy string = "redis_list_destroy"
+
+ EventForAccountLoginProduce string = "account_login_produce"
+ EventForSysLogProduce string = "sys_log_produce"
+)
+
+const (
+ DefaultChinaAreaCode string = "86"
+)
diff --git a/config/flag.go b/config/flag.go
new file mode 100644
index 0000000..e785351
--- /dev/null
+++ b/config/flag.go
@@ -0,0 +1,13 @@
+package config
+
+import "flag"
+
+var (
+ Mode = flag.String("mode", "release", "Development Environment") // debug,test,release
+ Version = flag.String("version", "v1.0", "IOT Version")
+)
+
+// IsDebug 开发版本
+func IsDebug() bool {
+ return *Mode == "debug"
+}
diff --git a/config/system.go b/config/system.go
new file mode 100644
index 0000000..50e345c
--- /dev/null
+++ b/config/system.go
@@ -0,0 +1,36 @@
+package config
+
+var SystemConfig = map[string]interface{}{}
+
+//png,jpg,csv,xls,xlsx,pcm,wav,amr,mp3,mp4,json
+
+// 基本配置
+const (
+ Name string = "name" // 名称
+ Domain string = "domain" // 域名
+ TokenEffectTime string = "token_effect_time" // Token有效时间
+ MultipleLogin string = "multiple_login" // 是否开启多地登录
+)
+
+const (
+ ServePort string = "serve_port" // 服务器端口
+)
+
+const (
+ WechatForAppID string = "appid"
+)
+
+const (
+ EmailForAlias string = "email_alias" // 邮件别名
+ EmailForHost string = "email_host" // 邮件Host
+ EmailForPort string = "email_port" // 邮件端口地址
+ EmailForUser string = "email_user" // 邮件用户
+ EmailForPass string = "email_pass" // 邮件密码;定义邮箱服务器连接信息,如果是阿里邮箱 email_pass填密码,qq邮箱填授权码
+)
+
+const (
+ UploadPath string = "upload_path" // 上传路径
+ UploadExt string = "upload_ext" // 上传文件限制
+ UploadSize string = "upload_size" // 上传文件大小限制
+ UploadRename string = "upload_rename" // 上传文件是否重命名
+)
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..b7f9265
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,32 @@
+module ArmedPolice
+
+go 1.16
+
+require (
+ github.com/antonfisher/nested-logrus-formatter v1.3.1
+ github.com/belief428/gorm-engine v1.0.1
+ github.com/dgrijalva/jwt-go v3.2.0+incompatible
+ github.com/elastic/go-elasticsearch/v7 v7.15.1
+ github.com/gin-gonic/gin v1.7.4
+ github.com/go-redis/redis v6.15.9+incompatible
+ github.com/jonboulle/clockwork v0.2.2 // indirect
+ github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
+ github.com/lestrrat-go/strftime v1.0.5 // indirect
+ github.com/mojocn/base64Captcha v1.3.5
+ github.com/onsi/ginkgo v1.16.5 // indirect
+ github.com/onsi/gomega v1.16.0 // indirect
+ github.com/pkg/errors v0.9.1
+ github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
+ github.com/satori/go.uuid v1.2.0
+ github.com/sirupsen/logrus v1.8.1
+ github.com/speps/go-hashids v1.0.0
+ github.com/spf13/cobra v1.2.1
+ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
+ golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
+ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
+ gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
+ gopkg.in/yaml.v2 v2.4.0
+ gorm.io/driver/mysql v1.1.3
+ gorm.io/driver/sqlite v1.2.3
+ gorm.io/gorm v1.22.2
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..71cd9b1
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,703 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
+cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
+cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
+cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
+cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
+cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
+cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
+cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
+cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
+cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
+cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
+cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
+cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
+cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI=
+cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
+cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg=
+cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8=
+cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0=
+cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
+cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
+cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
+cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
+cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
+cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
+cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
+cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
+cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
+cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
+cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
+cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
+cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
+cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
+cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
+cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
+cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
+cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
+dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
+github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
+github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ=
+github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA=
+github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
+github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
+github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
+github.com/belief428/gorm-engine v1.0.1 h1:hvCIsUYcSYJ+10bJmgJKIRJkEwLKvTNBrazlx5H54nk=
+github.com/belief428/gorm-engine v1.0.1/go.mod h1:zbN9iEeSRrK/Rkv3Midl4j9XqgsgDKsoqt+XwC+Qz1w=
+github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
+github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
+github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
+github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
+github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
+github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
+github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
+github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
+github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
+github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
+github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+github.com/elastic/go-elasticsearch/v7 v7.15.1 h1:Wd8RLHb5D8xPBU8vGlnLXyflkso9G+rCmsXjqH8LLQQ=
+github.com/elastic/go-elasticsearch/v7 v7.15.1/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
+github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
+github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
+github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
+github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
+github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
+github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
+github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
+github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
+github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=
+github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
+github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
+github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
+github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
+github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
+github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
+github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
+github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
+github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
+github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
+github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
+github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
+github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
+github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
+github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
+github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
+github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
+github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
+github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
+github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
+github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
+github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
+github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
+github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
+github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
+github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
+github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
+github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
+github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
+github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
+github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
+github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
+github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
+github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
+github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
+github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
+github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
+github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
+github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
+github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
+github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
+github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
+github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
+github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
+github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
+github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
+github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
+github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
+github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
+github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
+github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
+github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
+github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
+github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI=
+github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
+github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
+github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
+github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
+github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
+github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
+github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
+github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
+github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
+github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
+github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
+github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4=
+github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
+github.com/lestrrat-go/strftime v1.0.5 h1:A7H3tT8DhTz8u65w+JRpiBxM4dINQhUXAZnhBa2xeOE=
+github.com/lestrrat-go/strftime v1.0.5/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g=
+github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
+github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
+github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
+github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
+github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
+github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
+github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
+github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
+github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
+github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
+github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
+github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
+github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/mojocn/base64Captcha v1.3.5 h1:Qeilr7Ta6eDtG4S+tQuZ5+hO+QHbiGAJdi4PfoagaA0=
+github.com/mojocn/base64Captcha v1.3.5/go.mod h1:/tTTXn4WTpX9CfrmipqRytCpJ27Uw3G6I7NcP2WwcmY=
+github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
+github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
+github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
+github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
+github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
+github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
+github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
+github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
+github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
+github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c=
+github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
+github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
+github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo=
+github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM=
+github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
+github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
+github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
+github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
+github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
+github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
+github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/speps/go-hashids v1.0.0 h1:jdFC07PrExRM4Og5Ev4411Tox75aFpkC77NlmutadNI=
+github.com/speps/go-hashids v1.0.0/go.mod h1:P7hqPzMdnZOfyIk+xrlG1QaSMw+gCBdHKsBDnhpaZvc=
+github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
+github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
+github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
+github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
+github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
+github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
+github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
+github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
+github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
+go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
+go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
+go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
+go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
+go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
+go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
+go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
+go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
+go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
+golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
+golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
+golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
+golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
+golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
+golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
+golang.org/x/image v0.0.0-20190501045829-6d32002ffd75/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
+golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=
+golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
+golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
+golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
+golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
+golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
+golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
+golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
+golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
+golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs=
+golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
+golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
+golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
+golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
+golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
+golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
+google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
+google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
+google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
+google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
+google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
+google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
+google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
+google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
+google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU=
+google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94=
+google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
+google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
+google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
+google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
+google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
+google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
+google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
+google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
+google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
+google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
+google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
+google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
+google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
+google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
+google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
+google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
+google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
+google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
+google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
+google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
+google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
+google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
+google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
+google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
+gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
+gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
+gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
+gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gorm.io/driver/mysql v1.0.6/go.mod h1:KdrTanmfLPPyAOeYGyG+UpDys7/7eeWT1zCq+oekYnU=
+gorm.io/driver/mysql v1.1.3 h1:+5g1UElqN0sr2gZqmg9djlu1zT3cErHiscc6+IbLHgw=
+gorm.io/driver/mysql v1.1.3/go.mod h1:4P/X9vSc3WTrhTLZ259cpFd6xKNYiSSdSZngkSBGIMM=
+gorm.io/driver/sqlite v1.1.4/go.mod h1:mJCeTFr7+crvS+TRnWc5Z3UvwxUN1BGBLMrf5LA9DYw=
+gorm.io/driver/sqlite v1.2.3 h1:OwKm0xRAnsZMWAl5BtXJ9BsXAZHIt802DOTVMQuzWN8=
+gorm.io/driver/sqlite v1.2.3/go.mod h1:wkiGvZF3le/8vjCRYg0bT8TSw6APZ5rtgKW8uQYE3sc=
+gorm.io/gorm v1.20.7/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
+gorm.io/gorm v1.21.9/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
+gorm.io/gorm v1.21.12/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
+gorm.io/gorm v1.22.0/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
+gorm.io/gorm v1.22.2 h1:1iKcvyJnR5bHydBhDqTwasOkoo6+o4Ms5cknSt6qP7I=
+gorm.io/gorm v1.22.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
+honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
+honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
+rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
+rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
diff --git a/lib/config.go b/lib/config.go
new file mode 100644
index 0000000..5e2ecf7
--- /dev/null
+++ b/lib/config.go
@@ -0,0 +1,42 @@
+package lib
+
+import (
+ "encoding/json"
+ "io/ioutil"
+ "path"
+
+ "gopkg.in/yaml.v2"
+)
+
+type callback func(interface{})
+
+var loaders = map[string]func([]byte, interface{}) error{
+ ".json": LoadConfigFormJsonBytes,
+ ".yaml": LoadConfigFromYamlBytes,
+}
+
+func LoadConfigFormJsonBytes(content []byte, obj interface{}) error {
+ return json.Unmarshal(content, obj)
+}
+
+func LoadConfigFromYamlBytes(content []byte, obj interface{}) error {
+ return yaml.Unmarshal(content, obj)
+}
+
+func LoadConfig(file string, v interface{}, callback ...callback) {
+ content, err := ioutil.ReadFile(file)
+
+ if err != nil {
+ panic("Load Config Error " + err.Error())
+ }
+ loader, ok := loaders[path.Ext(file)]
+
+ if !ok {
+ panic("Unknown File Type:" + path.Ext(file))
+ }
+ if err = loader(content, v); err == nil {
+ for _, _callback := range callback {
+ _callback(v)
+ }
+ }
+}
diff --git a/lib/email.go b/lib/email.go
new file mode 100644
index 0000000..f554a10
--- /dev/null
+++ b/lib/email.go
@@ -0,0 +1,40 @@
+package lib
+
+import (
+ "gopkg.in/gomail.v2"
+)
+
+type Email struct {
+ *EmailOption
+}
+
+type EmailOption struct {
+ Alias, User, Pass string // Auth:定义邮箱服务器连接信息,如果是阿里邮箱 Pass填密码,qq邮箱填授权码
+ Host string
+ Port int
+}
+
+// EmailSendHandle 邮件发送处理
+// @objects:发送对象,多个邮件地址
+// @subject:邮件主题
+// @body:邮件正文
+type EmailSendHandle func(objects []string, subject, body string) error
+
+func (this *Email) Init() {
+
+}
+
+func (this *Email) Send() EmailSendHandle {
+ return func(objects []string, subject, body string) error {
+ m := gomail.NewMessage()
+ m.SetHeader("From", m.FormatAddress(this.User, this.Alias))
+ m.SetHeader("To", objects...)
+ m.SetHeader("Subject", subject)
+ m.SetBody("text/html", body)
+ return gomail.NewDialer(this.Host, this.Port, this.User, this.Pass).DialAndSend(m)
+ }
+}
+
+func NewEmail(option *EmailOption) *Email {
+ return &Email{option}
+}
diff --git a/lib/email_test.go b/lib/email_test.go
new file mode 100644
index 0000000..d9f475e
--- /dev/null
+++ b/lib/email_test.go
@@ -0,0 +1,41 @@
+package lib
+
+import (
+ "strconv"
+ "testing"
+
+ "gopkg.in/gomail.v2"
+)
+
+func SendMail(mailTo []string, subject string, body string) error {
+ //定义邮箱服务器连接信息,如果是阿里邮箱 pass填密码,qq邮箱填授权码
+ mailConn := map[string]string{
+ "alias": "postmaster",
+ "user": "postmaster@ipeace.org.cn",
+ "pass": "Email@henry!",
+ "host": "smtp.qiye.aliyun.com",
+ "port": "465",
+ }
+ port, _ := strconv.Atoi(mailConn["port"]) //转换端口类型为int
+
+ m := gomail.NewMessage()
+ m.SetHeader("From", m.FormatAddress(mailConn["user"], mailConn["alias"]))
+ m.SetHeader("To", mailTo...)
+ m.SetHeader("Subject", subject)
+ m.SetBody("text/html", body)
+
+ return gomail.NewDialer(mailConn["host"], port, mailConn["user"], mailConn["pass"]).DialAndSend(m)
+}
+
+func TestNewEmail(t *testing.T) {
+ //定义收件人
+ mailTo := []string{
+ "592856124@qq.com",
+ }
+ //邮件主题为"Hello"
+ subject := "Hello"
+ // 邮件正文
+ body := "Good"
+ err := SendMail(mailTo, subject, body)
+ t.Log(err)
+}
diff --git a/lib/upload.go b/lib/upload.go
new file mode 100644
index 0000000..53ae3f7
--- /dev/null
+++ b/lib/upload.go
@@ -0,0 +1,97 @@
+package lib
+
+import (
+ "Edu/utils"
+ "errors"
+ "fmt"
+ "mime/multipart"
+ "path/filepath"
+ "strings"
+ "time"
+)
+
+type (
+ UploadConfig struct {
+ Path string // 根目录,完整目录-更目录+时间
+ Ext []string // 文件类型
+ Size int64 // 文件大小
+ Rename bool // 重命名
+ }
+
+ UploadHandle struct {
+ Url string `json:"url"`
+ Filepath string `json:"filepath"`
+ Filename string `json:"filename"`
+ RelativePath string `json:"-"`
+ }
+)
+
+type (
+ Handle func(file *multipart.FileHeader, domain string) (*UploadHandle, error)
+)
+
+func (this *UploadConfig) ext(ext string) bool {
+ if !utils.InArray(strings.ToLower(ext), this.Ext) {
+ return false
+ }
+ return true
+}
+
+func (this *UploadConfig) size(size int64) bool {
+ if size > this.Size {
+ return false
+ }
+ return true
+}
+
+func (this *UploadConfig) Handle() Handle {
+ return func(file *multipart.FileHeader, domain string) (handle *UploadHandle, e error) {
+ ext := filepath.Ext(file.Filename)
+
+ if !this.ext(strings.Replace(ext, ".", "", 1)) {
+ return nil, errors.New("文件类型限制不可上传")
+ }
+
+ if !this.size(file.Size) {
+ return nil, errors.New("文件过大不可上传")
+ }
+ // 判断目录是否存在
+ now := time.Now()
+
+ this.Path += now.Format("20060102") + "/"
+
+ isExist, err := utils.PathExists(this.Path)
+
+ if err != nil {
+ return nil, err
+ }
+ if !isExist {
+ if err = utils.MkdirAll(this.Path); err != nil {
+ return nil, err
+ }
+ }
+ _file := file.Filename
+
+ if this.Rename {
+ file.Filename = utils.Md5String(file.Filename, fmt.Sprintf("%d", now.UnixNano()))
+ _file = file.Filename + ext
+ }
+ _filepath := "/" + this.Path + _file
+
+ return &UploadHandle{
+ Url: domain + _filepath,
+ Filepath: _filepath,
+ Filename: _file,
+ RelativePath: this.Path + _file,
+ }, nil
+ }
+}
+
+func Upload(path string, ext []string, size int64, rename bool) *UploadConfig {
+ return &UploadConfig{
+ Path: path,
+ Ext: ext,
+ Size: size,
+ Rename: rename,
+ }
+}
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..ee8a161
--- /dev/null
+++ b/main.go
@@ -0,0 +1,5 @@
+package main
+
+func main() {
+
+}
\ No newline at end of file
diff --git a/router/auth.go b/router/auth.go
new file mode 100644
index 0000000..bef9d22
--- /dev/null
+++ b/router/auth.go
@@ -0,0 +1,127 @@
+package router
+
+import (
+ "Edu/app/service"
+ "Edu/config"
+ cache2 "Edu/serve/cache"
+ "Edu/utils"
+ "fmt"
+ "net/http"
+ "time"
+
+ "github.com/gin-gonic/gin"
+)
+
+// SkipperURL 跳过验证
+type SkipperURL func(*gin.Context) bool
+
+// PermissionHandle 权限验证
+type PermissionHandle func(key string) gin.HandlerFunc
+
+// AddSkipperURL 添加路由
+func AddSkipperURL(url ...string) SkipperURL {
+ return func(c *gin.Context) bool {
+ path := c.Request.URL.Path
+ return utils.InArray(path, url)
+ }
+}
+
+// NeedLogin 需要登录
+func NeedLogin(skipperURL ...SkipperURL) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ if len(skipperURL) > 0 && skipperURL[0](c) {
+ c.Next()
+ return
+ }
+ token := c.GetHeader(config.APIRequestToken)
+
+ if token == "" {
+ c.JSON(http.StatusUnauthorized, gin.H{"message": "Token异常"})
+ c.Abort()
+ return
+ }
+ tokenInfo := utils.JWTDecrypt(token)
+
+ if tokenInfo == nil || len(tokenInfo) <= 0 {
+ c.JSON(http.StatusUnauthorized, gin.H{"message": "Token无效"})
+ c.Abort()
+ return
+ }
+ expTimestamp := utils.StringToInt64(fmt.Sprintf("%v", tokenInfo["exp"]))
+ expTime := time.Unix(expTimestamp, 0)
+ ok := expTime.After(time.Now())
+
+ if !ok {
+ c.JSON(http.StatusUnauthorized, gin.H{"message": "Token过期"})
+ c.Abort()
+ return
+ }
+ cache, _ := cache2.Cache.HGet(config.RedisKeyForAccount, fmt.Sprintf("%v", tokenInfo[config.TokenForUID]))
+
+ if cache == "" {
+ c.JSON(http.StatusUnauthorized, gin.H{"message": "用户未登录或已退出"})
+ c.Abort()
+ return
+ }
+ session := new(service.Session)
+ _ = session.UnmarshalBinary([]byte(cache))
+
+ if !config.SettingInfo.MultipleLogin && session.Token != token {
+ c.JSON(http.StatusUnauthorized, gin.H{"message": "登录失效,已在其他地方登录!"})
+ c.Abort()
+ return
+ }
+ c.Set(config.TokenForSession, session)
+ c.Next()
+ }
+}
+
+// NeedGradeParam 需要年级参数
+func NeedGradeParam(skipperURL ...SkipperURL) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ if len(skipperURL) > 0 && skipperURL[0](c) {
+ c.Next()
+ return
+ }
+ param := c.GetHeader(config.APIRequestGrade)
+
+ if param == "" {
+ c.JSON(http.StatusBadRequest, gin.H{"message": "参数异常"})
+ c.Abort()
+ return
+ }
+ grade := utils.StringToInt(param)
+
+ if grade <= 0 {
+ c.JSON(http.StatusBadRequest, gin.H{"message": "Grade异常"})
+ c.Abort()
+ return
+ }
+ c.Set(config.TokenForGrade, grade)
+ c.Next()
+ }
+}
+
+// NeedPermission 需要权限验证
+func NeedPermission(skipperURL ...SkipperURL) PermissionHandle {
+ return func(key string) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ if len(skipperURL) > 0 && skipperURL[0](c) {
+ c.Next()
+ return
+ }
+ //session, _ := c.Get(config.TokenForSession)
+ //_session := session.(*service.Session)
+
+ //if pass, _ := service.NewPermission(nil, &service.AuthRequest{
+ // Url: key,
+ // Method: c.Request.Method,
+ //})(_session.TenantKey, fmt.Sprintf("%d", _session.UID)).Enforce(); !pass {
+ // c.JSON(http.StatusOK, gin.H{"code": http.StatusForbidden, "msg": "无权限访问!"})
+ // c.Abort()
+ // return
+ //}
+ c.Next()
+ }
+ }
+}
diff --git a/router/middleware.go b/router/middleware.go
new file mode 100644
index 0000000..0f46e29
--- /dev/null
+++ b/router/middleware.go
@@ -0,0 +1,115 @@
+package router
+
+import (
+ "Edu/config"
+ "Edu/serve/logger"
+ "context"
+ "fmt"
+ "net/http"
+ "time"
+
+ "github.com/gin-gonic/gin"
+ "github.com/sirupsen/logrus"
+)
+
+func Cors() gin.HandlerFunc {
+ return func(c *gin.Context) {
+ method := c.Request.Method
+ c.Header("Access-Control-Allow-Origin", "*")
+ c.Header("Access-Control-Allow-Headers", "access-control-allow-origin, access-control-allow-headers, application/octet-stream")
+ c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
+ c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")
+ c.Header("Access-Control-Allow-Credentials", "true")
+
+ if method == "OPTIONS" {
+ c.AbortWithStatus(http.StatusNoContent)
+ return
+ }
+ c.Next()
+ }
+}
+
+// NoMethodHandler 未找到请求方法的处理函数
+func NoMethodHandler() gin.HandlerFunc {
+ return func(c *gin.Context) {
+ c.JSON(http.StatusMethodNotAllowed, gin.H{
+ "message": "未找到请求路由的处理函数",
+ })
+ c.Abort()
+ return
+ }
+}
+
+// NoRouteHandler 未找到请求路由的处理函数
+func NoRouteHandler() gin.HandlerFunc {
+ return func(c *gin.Context) {
+ c.JSON(http.StatusNotFound, gin.H{
+ "message": "未找到请求路由的处理函数",
+ })
+ c.Abort()
+ return
+ }
+}
+
+func LoggerHandle(log string, leastDay uint) gin.HandlerFunc {
+ _logger := logger.NewLogger().Init(&logger.Option{File: log, LeastDay: leastDay, Level: "debug", IsStdout: false}).Logger
+
+ return func(c *gin.Context) {
+ _logger.Log(logrus.InfoLevel, map[string]interface{}{
+ "Status": c.Writer.Status(),
+ "IP": c.ClientIP(),
+ "Method": c.Request.Method,
+ "Url": c.Request.RequestURI,
+ })
+ }
+}
+
+// TimeoutHandle 超时处理
+func TimeoutHandle(timeout time.Duration) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ ctx, cancel := context.WithTimeout(c.Request.Context(), timeout)
+
+ defer func() {
+ if ctx.Err() == context.DeadlineExceeded {
+ c.Writer.WriteHeader(http.StatusGatewayTimeout)
+ c.Abort()
+ }
+ cancel()
+ }()
+ c.Request = c.Request.WithContext(ctx)
+ c.Next()
+ }
+}
+
+// RecoveryHandler 崩溃恢复中间件
+func RecoveryHandler() gin.HandlerFunc {
+ return func(c *gin.Context) {
+ defer func() {
+ if err := recover(); err != nil {
+ fmt.Printf("Recover:request【%s】 error:【%v】\n", c.Request.URL, err)
+ c.JSON(http.StatusInternalServerError, gin.H{
+ "message": "Internal Server Error!",
+ })
+ c.Abort()
+ return
+ }
+ }()
+ c.Next()
+ }
+}
+
+// AnalysisParamsHandler 解析参数
+func AnalysisParamsHandler() gin.HandlerFunc {
+ return func(c *gin.Context) {
+ url := c.Request.URL
+
+ var data string
+
+ value, has := config.SystemConfig[url.String()]
+
+ if has {
+ data = value.(string)
+ }
+ c.Set(config.ContentForLocal, data)
+ }
+}
diff --git a/router/rate/ip.go b/router/rate/ip.go
new file mode 100644
index 0000000..eed9144
--- /dev/null
+++ b/router/rate/ip.go
@@ -0,0 +1,74 @@
+package rate
+
+import (
+ "net/http"
+ "sync"
+
+ "github.com/gin-gonic/gin"
+ "golang.org/x/time/rate"
+)
+
+// IPRateLimiter IP限流器
+type IPRateLimiter struct {
+ ips map[string]*rate.Limiter // IP地址库
+ limit int
+ capacity int
+ mutex *sync.RWMutex // 锁
+}
+
+type AllowHandle func(ctx *gin.Context) bool
+
+type IPRateLimiterConfig func(limit, capacity int) gin.HandlerFunc
+
+var IPRateLimiterHandle *IPRateLimiter
+
+// Handle
+func (this *IPRateLimiter) Handle() AllowHandle {
+ return func(ctx *gin.Context) bool {
+ ip := ctx.ClientIP()
+
+ this.mutex.RLock()
+ defer this.mutex.RUnlock()
+
+ limiter, exists := this.ips[ip]
+
+ if !exists {
+ limiter = rate.NewLimiter(rate.Limit(this.limit), this.capacity)
+ this.ips[ip] = limiter
+ }
+ return limiter.Allow()
+ }
+}
+
+// NewIPRateLimiter 初始化限流器
+func NewIPRateLimiter() IPRateLimiterConfig {
+ return func(limit, capacity int) gin.HandlerFunc {
+ IPRateLimiterHandle = &IPRateLimiter{
+ ips: make(map[string]*rate.Limiter, 0),
+ limit: limit,
+ capacity: capacity,
+ mutex: new(sync.RWMutex),
+ }
+ return nil
+ }
+}
+
+// RequestIPRateLimiter 请求限流
+func RequestIPRateLimiter() IPRateLimiterConfig {
+ return func(limit, capacity int) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ if IPRateLimiterHandle == nil {
+ NewIPRateLimiter()(limit, capacity)
+ }
+ if !IPRateLimiterHandle.Handle()(c) {
+ c.JSON(http.StatusOK, gin.H{
+ "code": http.StatusTooManyRequests,
+ "msg": "访问频率过快,请稍后访问!",
+ })
+ c.Abort()
+ return
+ }
+ c.Next()
+ }
+ }
+}
diff --git a/router/router.go b/router/router.go
new file mode 100644
index 0000000..8745c28
--- /dev/null
+++ b/router/router.go
@@ -0,0 +1,126 @@
+package router
+
+import (
+ "Edu/app/api"
+ "Edu/config"
+ "Edu/router/rate"
+ "io"
+ "net/http"
+ "os"
+ "time"
+
+ "github.com/gin-gonic/gin"
+)
+
+type Router struct {
+ *Option
+ handler *gin.Engine
+}
+
+type (
+ Option struct {
+ Mode string
+ IsCors bool
+ *RateLimitConfig
+ }
+ // RateLimitConfig 限流配置
+ RateLimitConfig struct {
+ IsRate bool `json:"is_rate"`
+ Limit int `json:"limit"`
+ Capacity int `json:"capacity"`
+ }
+)
+
+func (this *Router) registerAPI() {
+ apiPrefix := "/api"
+ g := this.handler.Group(apiPrefix)
+ g.Use()
+ // 登录验证
+ g.Use(NeedLogin(AddSkipperURL([]string{
+ apiPrefix + "/v1/account/authorize",
+ apiPrefix + "/v1/account/tourist",
+ apiPrefix + "/v1/index",
+ apiPrefix + "/v1/grade",
+ apiPrefix + "/v1/book/list",
+ }...)))
+ g.Use(NeedGradeParam(AddSkipperURL([]string{
+ apiPrefix + "/v1/account/authorize",
+ apiPrefix + "/v1/account/tourist",
+ apiPrefix + "/v1/grade",
+ }...)))
+ v1 := g.Group("/v1")
+ // Account 接口管理
+ account := v1.Group("/account")
+ {
+ _api := new(api.Account)
+ account.POST("/authorize", _api.Authorize)
+
+ if config.IsDebug() {
+ account.GET("/tourist", _api.Tourist)
+ }
+ }
+ // Banner 接口管理
+ v1.GET("/index", new(api.Index).Index)
+ v1.GET("/grade", new(api.Index).Grade)
+ v1.GET("/banner", new(api.Banner).List)
+ v1.GET("/book/list", new(api.Book).List)
+ // User 接口管理
+ user := v1.Group("/user")
+ {
+ _api := new(api.User)
+ user.GET("/info", _api.Info)
+ }
+ // Book 接口管理
+ book := v1.Group("/book")
+ {
+ _api := new(api.Book)
+ book.GET("/home", _api.Home)
+ //book.GET("/list", _api.List)
+ book.GET("/detail", _api.Detail)
+ book.POST("/play", _api.Play)
+ }
+ // Pay 支付管理
+ pay := v1.Group("/pay")
+ {
+ _api := new(api.Pay)
+ pay.POST("/launch", _api.Launch)
+ pay.POST("/notice", _api.Notify)
+ }
+}
+
+func (this *Router) Init() *gin.Engine {
+ gin.SetMode(this.Mode)
+
+ app := gin.New()
+
+ if this.IsCors {
+ app.Use(Cors())
+ }
+ app.NoRoute(NoRouteHandler())
+ app.NoMethod(NoMethodHandler())
+ app.Use(LoggerHandle("log/gin.log", 3))
+ app.Use(TimeoutHandle(time.Second * 30))
+ app.Use(RecoveryHandler())
+
+ if this.RateLimitConfig != nil {
+ if this.RateLimitConfig.IsRate {
+ rate.NewIPRateLimiter()(this.RateLimitConfig.Limit, this.RateLimitConfig.Capacity)
+ app.Use(rate.RequestIPRateLimiter()(this.RateLimitConfig.Limit, this.RateLimitConfig.Capacity))
+ }
+ }
+ if config.IsDebug() {
+ gin.DefaultWriter = io.MultiWriter(os.Stdout)
+ app.StaticFS("/api-docs", http.Dir("./doc"))
+ }
+ app.StaticFS("/upload", http.Dir("./upload"))
+ app.MaxMultipartMemory = 4 << 20
+ this.handler = app
+ // 注册路由
+ this.registerAPI()
+
+ return app
+}
+
+func NewRouter(option *Option) *Router {
+ return &Router{Option: option}
+}
diff --git a/serve/cache/init.go b/serve/cache/init.go
new file mode 100644
index 0000000..436c6f4
--- /dev/null
+++ b/serve/cache/init.go
@@ -0,0 +1,44 @@
+package cache
+
+import (
+ "Edu/config"
+ "Edu/serve/cache/logic"
+ "fmt"
+)
+
+var (
+ Cache logic.ICache
+
+ engines = map[string]func() logic.ICache{
+ "memory": memory, "redis": redis,
+ }
+)
+
+func memory() logic.ICache {
+ return logic.NewMemory()
+}
+
+func redis() logic.ICache {
+ return logic.NewRedis(&logic.RedisOption{
+ Addr: config.SettingInfo.Cache.Redis.Addr,
+ Password: config.SettingInfo.Cache.Redis.Password,
+ DB: config.SettingInfo.Cache.Redis.DB,
+ MinIdleConns: config.SettingInfo.Cache.Redis.MaxIdle,
+ IdleTimeout: config.SettingInfo.Cache.Redis.IdleTimeout,
+ })
+}
+
+func Init() {
+ handle, has := engines[config.SettingInfo.Cache.Type]
+
+ if !has {
+ panic(fmt.Sprintf("Unknown Cache Engine Mode:%s", config.SettingInfo.Cache.Type))
+ }
+ Cache = handle()
+
+ err := Cache.Run()
+
+ if err != nil {
+ panic("Cache Run Error:" + err.Error())
+ }
+}
diff --git a/serve/cache/logic/cache.go b/serve/cache/logic/cache.go
new file mode 100644
index 0000000..10dfa4a
--- /dev/null
+++ b/serve/cache/logic/cache.go
@@ -0,0 +1,28 @@
+package logic
+
+type ICache interface {
+ Set(key string, value interface{}, expiration int) error
+ Get(key string) (string, error)
+ Del(key string) error
+ ZAdd(key string, members ...*ScoreParams) error
+ ZRangebyscore(key string, opt *ScoreRangeBy) ([]string, error)
+ ZRem(key string, members ...interface{}) error
+ HExists(key, field string) (bool, error)
+ HSet(key, field string, value interface{}) error
+ HGet(key, field string) (string, error)
+ HDel(key string, fields ...string) error
+ SAdd(key string, members ...interface{}) error
+ SIsMember(key string, members interface{}) (bool, error)
+ SRem(key string, members ...interface{}) error
+ Run() error
+}
+
+type ScoreParams struct {
+ Score float64
+ Member interface{}
+}
+
+type ScoreRangeBy struct {
+ Min, Max string
+ Offset, Count int64
+}
diff --git a/serve/cache/logic/memory.go b/serve/cache/logic/memory.go
new file mode 100644
index 0000000..c5ed6c5
--- /dev/null
+++ b/serve/cache/logic/memory.go
@@ -0,0 +1,177 @@
+package logic
+
+import (
+ "Edu/utils"
+ "strings"
+ "sync"
+)
+
+type Memory struct {
+ cache map[string]interface{}
+ cacheList []interface{}
+ cacheSorted map[string][]*ScoreParams
+ locker *sync.RWMutex
+}
+
+func (this *Memory) Set(key string, value interface{}, expiration int) error {
+ this.locker.Lock()
+ defer this.locker.Unlock()
+ this.cache[key] = value
+ return nil
+}
+
+// Get
+func (this *Memory) Get(key string) (string, error) {
+ this.locker.RLock()
+ defer this.locker.RUnlock()
+ data, has := this.cache[key]
+
+ if !has {
+ return "", nil
+ }
+ return utils.AnyToJSON(data), nil
+}
+
+// Del
+func (this *Memory) Del(key string) error {
+ this.locker.Lock()
+ defer this.locker.Unlock()
+ delete(this.cache, key)
+ return nil
+}
+
+func (this *Memory) ZAdd(key string, members ...*ScoreParams) error {
+ this.locker.Lock()
+ defer this.locker.Unlock()
+ if _, has := this.cacheSorted[key]; !has {
+ this.cacheSorted[key] = members
+ } else {
+ this.cacheSorted[key] = append(this.cacheSorted[key], members...)
+ }
+ return nil
+}
+
+func (this *Memory) ZRangebyscore(key string, opt *ScoreRangeBy) ([]string, error) {
+ this.locker.Lock()
+ defer this.locker.Unlock()
+ if _, has := this.cacheSorted[key]; !has {
+ return []string{}, nil
+ }
+ out := make([]string, 0)
+
+ function := func(src string) (float64, bool) {
+ contain := false
+
+ if strings.Contains(opt.Min, "(") {
+ src = strings.Replace(src, "(", "", 1)
+ contain = true
+ }
+ f, _ := utils.StringToFloat(src)
+ return f, contain
+ }
+ min, minContain := function(opt.Min)
+ max, maxContain := function(opt.Max)
+
+ for _, v := range this.cacheSorted[key] {
+ if ((v.Score >= min && minContain) || v.Score > min) &&
+ ((v.Score <= max && maxContain) || v.Score < max) {
+ out = append(out, utils.AnyToJSON(v.Member))
+
+ if opt.Count > 0 && int64(len(out)) > opt.Count {
+ return out, nil
+ }
+ }
+ }
+ return out, nil
+}
+
+func (this *Memory) ZRem(key string, members ...interface{}) error {
+ this.locker.Lock()
+ defer this.locker.Unlock()
+ if _, has := this.cacheSorted[key]; !has {
+ return nil
+ }
+ for k, v := range this.cacheSorted[key] {
+ for _, member := range members {
+ if v.Member == member {
+ this.cacheSorted[key] = append(this.cacheSorted[key][:k], this.cacheSorted[key][k+1:]...)
+ break
+ }
+ }
+ }
+ return nil
+}
+
+// HExists HASH Exist
+func (this *Memory) HExists(key, field string) (bool, error) {
+ return this.cache[key] != nil, nil
+}
+
+// HSet HASH Set
+func (this *Memory) HSet(key, field string, value interface{}) error {
+ this.locker.Lock()
+ defer this.locker.Unlock()
+ this.cache[key] = value
+ return nil
+}
+
+// HGet Hash Get
+func (this *Memory) HGet(key, field string) (string, error) {
+ this.locker.RLock()
+ defer this.locker.RUnlock()
+ data, has := this.cache[key]
+
+ if !has {
+ return "", nil
+ }
+ return utils.AnyToJSON(data), nil
+}
+
+// HDel HASH Del
+func (this *Memory) HDel(key string, fields ...string) error {
+ this.locker.Lock()
+ defer this.locker.Unlock()
+ delete(this.cache, key)
+ return nil
+}
+
+// SAdd
+func (this *Memory) SAdd(key string, members ...interface{}) error {
+ this.locker.Lock()
+ defer this.locker.Unlock()
+ this.cacheList = append(this.cacheList, members...)
+ return nil
+}
+
+// SIsMember
+func (this *Memory) SIsMember(key string, members interface{}) (bool, error) {
+ this.locker.RLock()
+ defer this.locker.RUnlock()
+ return utils.InArray(members, this.cacheList), nil
+}
+
+// SRem
+func (this *Memory) SRem(key string, members ...interface{}) error {
+ this.locker.Lock()
+ defer this.locker.Unlock()
+
+ for k, v := range this.cacheList {
+ if utils.InArray(v, members) {
+ this.cacheList = append(this.cacheList[:k], this.cacheList[k+1:]...)
+ }
+ }
+ return nil
+}
+
+func (this *Memory) Run() error {
+ return nil
+}
+
+func NewMemory() *Memory {
+ return &Memory{
+ cache: make(map[string]interface{}, 0),
+ cacheList: make([]interface{}, 0),
+ cacheSorted: make(map[string][]*ScoreParams, 0),
+ locker: new(sync.RWMutex),
+ }
+}
diff --git a/serve/cache/logic/redis.go b/serve/cache/logic/redis.go
new file mode 100644
index 0000000..553ac0a
--- /dev/null
+++ b/serve/cache/logic/redis.go
@@ -0,0 +1,114 @@
+package logic
+
+import (
+ "time"
+
+ "github.com/pkg/errors"
+
+ "github.com/go-redis/redis"
+)
+
+type Redis struct {
+ *RedisOption
+}
+
+type RedisOption struct {
+ Addr string
+ Password string
+ DB int
+ MinIdleConns int
+ IdleTimeout int
+}
+
+var RedisClient *redis.Client
+
+// Set
+func (this *Redis) Set(key string, value interface{}, expiration int) error {
+ return RedisClient.Set(key, value, time.Duration(expiration)*time.Second).Err()
+}
+
+// Get
+func (this *Redis) Get(key string) (string, error) {
+ return RedisClient.Get(key).Result()
+}
+
+// Del
+func (this *Redis) Del(key string) error {
+ return RedisClient.Del(key).Err()
+}
+
+func (this *Redis) ZAdd(key string, members ...*ScoreParams) error {
+ redisZ := make([]redis.Z, 0)
+
+ for _, v := range members {
+ redisZ = append(redisZ, redis.Z{Score: v.Score, Member: v.Member})
+ }
+ return RedisClient.ZAdd(key, redisZ...).Err()
+}
+
+func (this *Redis) ZRangebyscore(key string, opt *ScoreRangeBy) ([]string, error) {
+ return RedisClient.ZRangeByScore(key, redis.ZRangeBy{Min: opt.Min, Max: opt.Max, Offset: opt.Offset, Count: opt.Count}).Result()
+}
+
+func (this *Redis) ZRem(key string, members ...interface{}) error {
+ return RedisClient.ZRem(key, members...).Err()
+}
+
+// HExists HASH Exist
+func (this *Redis) HExists(key, field string) (bool, error) {
+ return RedisClient.HExists(key, field).Result()
+}
+
+// HSet HASH Set
+func (this *Redis) HSet(key, field string, value interface{}) error {
+ return RedisClient.HSet(key, field, value).Err()
+}
+
+// HGet Hash Get
+func (this *Redis) HGet(key, field string) (string, error) {
+ return RedisClient.HGet(key, field).Result()
+}
+
+// HDel HASH Del
+func (this *Redis) HDel(key string, fields ...string) error {
+ return RedisClient.HDel(key, fields...).Err()
+}
+
+// SAdd
+func (this *Redis) SAdd(key string, members ...interface{}) error {
+ return RedisClient.SAdd(key, members...).Err()
+}
+
+// SIsMember
+func (this *Redis) SIsMember(key string, members interface{}) (bool, error) {
+ return RedisClient.SIsMember(key, members).Result()
+}
+
+// SRem
+func (this *Redis) SRem(key string, members ...interface{}) error {
+ return RedisClient.SRem(key, members...).Err()
+}
+
+// Run 开启
+func (this *Redis) Run() error {
+ option := &redis.Options{
+ Network: "",
+ Addr: this.Addr,
+ Password: this.Password,
+ DB: this.DB,
+ MinIdleConns: this.MinIdleConns,
+ IdleTimeout: time.Duration(this.IdleTimeout),
+ }
+ RedisClient = redis.NewClient(option)
+
+ ping, err := RedisClient.Ping().Result()
+
+ if err != nil {
+ return errors.New(ping + err.Error())
+ }
+ return nil
+}
+
+func NewRedis(option *RedisOption) *Redis {
+ return &Redis{option}
+}
diff --git a/serve/cache/logic/redis_test.go b/serve/cache/logic/redis_test.go
new file mode 100644
index 0000000..7845da0
--- /dev/null
+++ b/serve/cache/logic/redis_test.go
@@ -0,0 +1,32 @@
+package logic
+
+import (
+ "github.com/go-redis/redis"
+ "testing"
+)
+
+var redisClient *redis.Client
+
+func InitRedis() {
+ option := &redis.Options{
+ Network: "",
+ //Addr: this.Addr,
+ //Password: this.Password,
+ //DB: this.DB,
+ //MinIdleConns: this.MinIdleConns,
+ //IdleTimeout: time.Duration(this.IdleTimeout),
+ }
+ redisClient = redis.NewClient(option)
+
+ ping, err := redisClient.Ping().Result()
+
+ if err != nil {
+ panic(ping + err.Error())
+ }
+}
+
+func TestNewRedis(t *testing.T) {
+ InitRedis()
+
+ //redisClient.
+}
diff --git a/serve/es/es.go b/serve/es/es.go
new file mode 100644
index 0000000..fb7ab6c
--- /dev/null
+++ b/serve/es/es.go
@@ -0,0 +1,32 @@
+package es
+
+import "github.com/elastic/go-elasticsearch/v7"
+
+type Es struct{ *EsConfig }
+
+type EsConfig struct {
+ Address []string
+}
+
+type EsServer func(*EsConfig) *Es
+
+var esClient = new(elasticsearch.Client)
+
+func (this *Es) Run() {
+ obj := elasticsearch.Config{
+ Addresses: this.Address,
+ Username: "",
+ Password: "",
+ }
+ var err error
+
+ if esClient, err = elasticsearch.NewClient(obj); err != nil {
+ panic("Elasticsearch Error " + err.Error())
+ }
+}
+
+func NewEs() EsServer {
+ return func(config *EsConfig) *Es {
+ return &Es{config}
+ }
+}
diff --git a/serve/es/serve.go b/serve/es/serve.go
new file mode 100644
index 0000000..9af4c34
--- /dev/null
+++ b/serve/es/serve.go
@@ -0,0 +1,5 @@
+package es
+
+func Set() {
+ esClient.Search()
+}
diff --git a/serve/logger/hook.go b/serve/logger/hook.go
new file mode 100644
index 0000000..bcd59b5
--- /dev/null
+++ b/serve/logger/hook.go
@@ -0,0 +1,89 @@
+package logger
+
+import (
+ "Edu/utils"
+ "fmt"
+ "os"
+ "path/filepath"
+ "runtime"
+ "time"
+
+ nested "github.com/antonfisher/nested-logrus-formatter"
+ rotatelogs "github.com/lestrrat-go/file-rotatelogs"
+ "github.com/rifflock/lfshook"
+ log "github.com/sirupsen/logrus"
+)
+
+// Hook
+type Hook struct {
+ Path string
+ File string
+}
+
+// Levels 只定义 error, warn, panic 等级的日志,其他日志等级不会触发 hook
+func (this *Hook) Levels() []log.Level {
+ return []log.Level{
+ log.WarnLevel,
+ log.ErrorLevel,
+ log.PanicLevel,
+ }
+}
+
+// Fire 将异常日志写入到指定日志文件中
+func (this *Hook) Fire(entry *log.Entry) error {
+ if isExist, _ := utils.PathExists(this.Path); !isExist {
+ utils.MkdirAll(this.Path)
+ }
+ f, err := os.OpenFile(this.Path+this.File, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
+
+ if err != nil {
+ return err
+ }
+ _, err = f.Write(utils.AnyToByte(entry.Data))
+
+ return err
+}
+
+func formatter(isConsole bool) *nested.Formatter {
+ fmtter := &nested.Formatter{
+ HideKeys: true,
+ TimestampFormat: "2006-01-02 15:04:05",
+ CallerFirst: true,
+ CustomCallerFormatter: func(frame *runtime.Frame) string {
+ funcInfo := runtime.FuncForPC(frame.PC)
+ if funcInfo == nil {
+ return "error during runtime.FuncForPC"
+ }
+ fullPath, line := funcInfo.FileLine(frame.PC)
+ return fmt.Sprintf(" [%v:%v]", filepath.Base(fullPath), line)
+ },
+ }
+ if isConsole {
+ fmtter.NoColors = false
+ } else {
+ fmtter.NoColors = true
+ }
+ return fmtter
+}
+
+// NewHook
+func NewHook(logName string, rotationTime time.Duration, leastDay uint) log.Hook {
+ writer, err := rotatelogs.New(
+ // 日志文件
+ logName+".%Y%m%d",
+ rotatelogs.WithRotationCount(leastDay), // 只保留最近的N个日志文件
+ )
+ if err != nil {
+ panic(err)
+ }
+ lfsHook := lfshook.NewHook(lfshook.WriterMap{
+ log.DebugLevel: writer,
+ log.InfoLevel: writer,
+ log.WarnLevel: writer,
+ log.ErrorLevel: writer,
+ log.FatalLevel: writer,
+ log.PanicLevel: writer,
+ }, formatter(false))
+
+ return lfsHook
+}
diff --git a/serve/logger/init.go b/serve/logger/init.go
new file mode 100644
index 0000000..c7f660e
--- /dev/null
+++ b/serve/logger/init.go
@@ -0,0 +1,63 @@
+package logger
+
+import (
+ "io"
+ "os"
+
+ log "github.com/sirupsen/logrus"
+)
+
+type Logger struct {
+ *Option
+ Logger *log.Logger
+}
+
+type Option struct {
+ File string `json:"file"`
+ LeastDay uint `json:"least_day"`
+ Level string `json:"level"`
+ IsStdout bool `json:"is_stdout"`
+}
+
+var logger *log.Logger
+
+var loggerLevel = map[string]log.Level{
+ "debug": log.DebugLevel,
+ "info": log.InfoLevel,
+ "warn": log.WarnLevel,
+ "error": log.ErrorLevel,
+}
+
+func (this *Logger) level() log.Level {
+ if _, has := loggerLevel[this.Level]; !has {
+ return log.ErrorLevel
+ }
+ return loggerLevel[this.Level]
+}
+
+func (this *Logger) Load() {
+ logger = this.Logger
+}
+
+func (this *Logger) Init(option *Option) *Logger {
+ this.Option = option
+
+ logger = log.New()
+ logger.SetFormatter(&log.JSONFormatter{TimestampFormat: "2006-01-02 15:04:05"})
+ logger.SetReportCaller(true)
+ logger.AddHook(NewHook(this.File, 0, this.LeastDay))
+
+ if this.IsStdout {
+ logger.SetOutput(io.MultiWriter(os.Stdout))
+ }
+ logger.SetFormatter(formatter(true))
+ logger.SetLevel(this.level())
+
+ this.Logger = logger
+
+ return this
+}
+
+func NewLogger() *Logger {
+ return &Logger{}
+}
diff --git a/serve/logger/serve.go b/serve/logger/serve.go
new file mode 100644
index 0000000..1c0aa22
--- /dev/null
+++ b/serve/logger/serve.go
@@ -0,0 +1,37 @@
+package logger
+
+import "github.com/sirupsen/logrus"
+
+func Warn(args ...interface{}) {
+ logger.Log(logrus.WarnLevel, args...)
+}
+
+func Error(args ...interface{}) {
+ logger.Log(logrus.ErrorLevel, args...)
+}
+
+func Fatal(args ...interface{}) {
+ logger.Log(logrus.FatalLevel, args...)
+ logger.Exit(1)
+}
+
+func Panic(args ...interface{}) {
+ logger.Log(logrus.PanicLevel, args...)
+}
+
+func WarnF(format string, args ...interface{}) {
+ logger.Logf(logrus.WarnLevel, format, args...)
+}
+
+func ErrorF(format string, args ...interface{}) {
+ logger.Logf(logrus.ErrorLevel, format, args...)
+}
+
+func FatalF(format string, args ...interface{}) {
+ logger.Logf(logrus.FatalLevel, format, args...)
+ logger.Exit(1)
+}
+
+func PanicF(format string, args ...interface{}) {
+ logger.Logf(logrus.PanicLevel, format, args...)
+}
diff --git a/serve/orm/logic/engine.go b/serve/orm/logic/engine.go
new file mode 100644
index 0000000..d6bbbe9
--- /dev/null
+++ b/serve/orm/logic/engine.go
@@ -0,0 +1,7 @@
+package logic
+
+import "gorm.io/gorm"
+
+type IEngine interface {
+ DSN() gorm.Dialector
+}
diff --git a/serve/orm/logic/mysql.go b/serve/orm/logic/mysql.go
new file mode 100644
index 0000000..2c51bf0
--- /dev/null
+++ b/serve/orm/logic/mysql.go
@@ -0,0 +1,20 @@
+package logic
+
+import (
+ "fmt"
+
+ "gorm.io/driver/mysql"
+ "gorm.io/gorm"
+)
+
+type Mysql struct {
+ User, Password, Host string
+ Port int
+ DBName, Parameters string
+}
+
+func (this *Mysql) DSN() gorm.Dialector {
+ return mysql.Open(fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?%s",
+ this.User, this.Password, this.Host, this.Port, this.DBName, this.Parameters,
+ ))
+}
diff --git a/serve/orm/logic/sqlite.go b/serve/orm/logic/sqlite.go
new file mode 100644
index 0000000..6a61576
--- /dev/null
+++ b/serve/orm/logic/sqlite.go
@@ -0,0 +1,19 @@
+package logic
+
+import (
+ "github.com/belief428/gorm-engine/tools"
+ "gorm.io/driver/sqlite"
+ "gorm.io/gorm"
+)
+
+type Sqlite struct {
+ Path string
+ Name string
+}
+
+func (this *Sqlite) DSN() gorm.Dialector {
+ if isExist, _ := tools.PathExists(this.Path); !isExist {
+ _ = tools.MkdirAll(this.Path)
+ }
+ return sqlite.Open(this.Path + "/" + this.Name)
+}
diff --git a/serve/orm/orm.go b/serve/orm/orm.go
new file mode 100644
index 0000000..e9e0366
--- /dev/null
+++ b/serve/orm/orm.go
@@ -0,0 +1,79 @@
+package orm
+
+import (
+ "Edu/config"
+ "Edu/serve/orm/logic"
+ "fmt"
+ "log"
+ "os"
+ "time"
+
+ "gorm.io/gorm/logger"
+ "gorm.io/gorm/schema"
+
+ "gorm.io/gorm"
+)
+
+var (
+ orm *gorm.DB
+
+ engines = map[string]func() logic.IEngine{
+ "mysql": mysql, "sqlite": sqlite,
+ }
+)
+
+func mysql() logic.IEngine {
+ return &logic.Mysql{
+ User: config.SettingInfo.Engine.Mysql.User, Password: config.SettingInfo.Engine.Mysql.Password,
+ Host: config.SettingInfo.Engine.Mysql.Host, Port: config.SettingInfo.Engine.Mysql.Port,
+ DBName: config.SettingInfo.Engine.Mysql.DBName, Parameters: config.SettingInfo.Engine.Mysql.Parameters,
+ }
+}
+
+func sqlite() logic.IEngine {
+ return &logic.Sqlite{Path: config.SettingInfo.Engine.Sqlite.Path, Name: config.SettingInfo.Engine.Sqlite.Name}
+}
+
+func Init() {
+ handle, has := engines[config.SettingInfo.Engine.DBMode]
+
+ if !has {
+ panic(fmt.Sprintf("Unknown Engine Mode:%d", config.SettingInfo.Engine.DBMode))
+ }
+ option := &gorm.Config{
+ DisableForeignKeyConstraintWhenMigrating: true,
+ NamingStrategy: schema.NamingStrategy{
+ TablePrefix: config.SettingInfo.Engine.TablePrefix,
+ SingularTable: !config.SettingInfo.Engine.Complex,
+ },
+ }
+ if config.SettingInfo.Engine.Debug {
+ option.Logger = logger.New(
+ log.New(os.Stdout, "\r\n", log.LstdFlags),
+ logger.Config{
+ SlowThreshold: time.Second,
+ LogLevel: logger.Info,
+ Colorful: false,
+ IgnoreRecordNotFoundError: true,
+ },
+ )
+ }
+ db, err := gorm.Open(handle().DSN(), option)
+
+ if err != nil {
+ panic("Orm Open Error:" + err.Error())
+ }
+ _db, _ := db.DB()
+ _db.SetMaxIdleConns(config.SettingInfo.Engine.MaxIdleConns)
+ _db.SetMaxOpenConns(config.SettingInfo.Engine.MaxOpenConns)
+ _db.SetConnMaxLifetime(time.Duration(config.SettingInfo.Engine.MaxLifetime) * time.Second)
+
+ orm = db
+}
+
+func GetDB() *gorm.DB {
+ if _, err := orm.DB(); err != nil {
+ Init()
+ }
+ return orm
+}
diff --git a/serve/web/web.go b/serve/web/web.go
new file mode 100644
index 0000000..14a263b
--- /dev/null
+++ b/serve/web/web.go
@@ -0,0 +1,62 @@
+package web
+
+import (
+ "fmt"
+ "net/http"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+)
+
+type Web struct {
+ *WebConfig
+ httpServer *http.Server
+}
+
+type WebConfig struct {
+ Port, ReadTimeout, WriteTimeout, IdleTimeout int
+}
+
+type WebServer func(config *WebConfig) *Web
+
+func (this *Web) stop() {
+ c := make(chan os.Signal)
+ signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGTERM)
+
+ go func() {
+ defer func() {
+ if err := recover(); err != nil {
+ err = fmt.Errorf("internal error: %v", err)
+ }
+ }()
+ s := <-c
+ defer close(c)
+ signal.Stop(c)
+ fmt.Printf("Http Server Stop:Closed - %d\n", s)
+ os.Exit(0)
+ }()
+}
+
+func (this *Web) Run(handler http.Handler) {
+ this.httpServer = &http.Server{
+ Addr: fmt.Sprintf(":%d", this.Port),
+ Handler: handler,
+ ReadTimeout: time.Duration(this.ReadTimeout) * time.Second,
+ WriteTimeout: time.Duration(this.WriteTimeout) * time.Second,
+ IdleTimeout: time.Duration(this.IdleTimeout) * time.Second,
+ MaxHeaderBytes: 1 << 20,
+ }
+ this.stop()
+
+ fmt.Println("Http Server Start")
+ fmt.Printf("Http Server Address - %v\n", fmt.Sprintf("http://127.0.0.1:%d", this.Port))
+
+ _ = this.httpServer.ListenAndServe()
+}
+
+func NewWeb() WebServer {
+ return func(config *WebConfig) *Web {
+ return &Web{WebConfig: config}
+ }
+}
diff --git a/server.sh b/server.sh
new file mode 100644
index 0000000..c29dcf3
--- /dev/null
+++ b/server.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+# date
+# 替换为你自己的执行程序
+APP_NAME=main
+# 项目的路径(替换成项目的路径)
+PROJECT_LOCATION=/home/www/SciencesServer
+usage() {
+ echo "Usage: sh 执行脚本.sh [start|stop|restart|status]"
+ exit 1
+}
+is_exist(){
+ pid=`ps -ef|grep ./$APP_NAME|grep -v grep|awk '{print $2}' `
+ #如果不存在返回1,存在返回0
+ if [ -z "${pid}" ]; then
+ #return 1
+ proct=1
+ else
+ #return 0
+ proct=0
+ fi
+}
+start(){
+ is_exist
+ if [ $proct -eq 0 ]; then
+ echo "${APP_NAME} is already running. pid=${pid} ."
+ else
+ cd ${PROJECT_LOCATION}
+ #nohup java -Xms256m -Xmx256m -jar $APP_NAME > /dev/null 2>&1 &
+ nohup ./$APP_NAME > /dev/null 2>&1 &
+ echo "${APP_NAME} is start"
+ fi
+}
+stop(){
+ is_exist
+ if [ $proct -eq 0 ]; then
+ cd ${PROJECT_LOCATION}
+ kill -9 $pid
+ echo "${APP_NAME} is stop"
+ else
+ echo "${APP_NAME} is not running"
+ fi
+}
+status(){
+ is_exist
+ if [ $proct -eq 0 ]; then
+ echo "${APP_NAME} is running. pid is ${pid}"
+ else
+ echo "${APP_NAME} is not running."
+ fi
+}
+restart(){
+ stop
+ start
+}
+# 根据输入参数,选择执行对应方法,不输入则执行使用说明
+case "$1" in
+ "start")
+ start
+ ;;
+ "stop")
+ stop
+ ;;
+ "status")
+ status
+ ;;
+ "restart")
+ restart
+ ;;
+ *)
+ usage
+ ;;
+esac
\ No newline at end of file
diff --git a/task/init.go b/task/init.go
new file mode 100644
index 0000000..74bda52
--- /dev/null
+++ b/task/init.go
@@ -0,0 +1,9 @@
+package task
+
+func Init() {
+ NewTaskListen().Listen()
+
+ //NewTask()("order", 60, NewOrder()).Push()
+
+ NewTaskQueue().Queue()
+}
diff --git a/task/listen.go b/task/listen.go
new file mode 100644
index 0000000..bf63562
--- /dev/null
+++ b/task/listen.go
@@ -0,0 +1,59 @@
+package task
+
+import (
+ "Edu/config"
+ "Edu/serve/cache"
+ "Edu/serve/cache/logic"
+ "Edu/utils"
+ "fmt"
+ "sync"
+)
+
+type TaskListen struct {
+ Produce chan *Task
+ Consume chan *Task
+ lock *sync.Mutex
+}
+
+var TaskListenEvent *TaskListen
+
+func (this *TaskListen) Join(task *Task) {
+ TaskListenEvent.Produce <- task
+}
+
+func (this *TaskListen) Quit(task *Task) {
+ TaskListenEvent.Consume <- task
+}
+
+func (this *TaskListen) Listen() {
+ go utils.TryCatch(func() {
+ for {
+ select {
+ case p := <-this.Produce:
+ err := cache.Cache.ZAdd(config.RedisKeyForTaskQueue, &logic.ScoreParams{Score: float64(p.DelayUnix()), Member: p.ID})
+
+ if err != nil {
+ fmt.Printf("Task Produce Redis Sadd Error【%s】", err)
+ } else {
+ err = cache.Cache.HSet(config.RedisKeyForTaskQueueBody, p.ID, p)
+ fmt.Printf("err:%v\n", err)
+ }
+ case c := <-this.Consume:
+ if err := c.Handle(); err != nil {
+ fmt.Printf("err:%v\n", err)
+ }
+ }
+ }
+ })
+}
+
+func NewTaskListen() *TaskListen {
+ if TaskListenEvent == nil {
+ TaskListenEvent = &TaskListen{
+ Produce: make(chan *Task, 1),
+ Consume: make(chan *Task, 1),
+ lock: new(sync.Mutex),
+ }
+ }
+ return TaskListenEvent
+}
diff --git a/task/order.go b/task/order.go
new file mode 100644
index 0000000..d482655
--- /dev/null
+++ b/task/order.go
@@ -0,0 +1,27 @@
+package task
+
+import (
+ "Edu/utils"
+ "encoding/json"
+)
+
+type Order struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+}
+
+func (this *Order) MarshalBinary() ([]byte, error) {
+ return json.Marshal(this)
+}
+
+func (this *Order) UnmarshalBinary(data []byte) error {
+ return utils.FromJSONBytes(data, this)
+}
+
+func (this *Order) Handle() error {
+ return nil
+}
+
+func NewOrder() *Order {
+ return &Order{ID: "23", Name: "Henry"}
+}
diff --git a/task/queue.go b/task/queue.go
new file mode 100644
index 0000000..87843eb
--- /dev/null
+++ b/task/queue.go
@@ -0,0 +1,41 @@
+package task
+
+import (
+ "Edu/config"
+ cache2 "Edu/serve/cache"
+ "Edu/serve/cache/logic"
+ "Edu/utils"
+ "fmt"
+ "time"
+)
+
+type TaskQueue struct{}
+
+func (this *TaskQueue) Queue() {
+ go utils.TryCatch(func() {
+ for {
+ now := time.Now()
+
+ cache, _ := cache2.Cache.ZRangebyscore(config.RedisKeyForTaskQueue, &logic.ScoreRangeBy{Min: "0",
+ Max: fmt.Sprintf("%d", now.Unix())})
+
+ if len(cache) > 0 {
+ for _, v := range cache {
+ body, _ := cache2.Cache.HGet(config.RedisKeyForTaskQueueBody, v)
+ task := new(Task)
+ _ = task.UnmarshalBinary([]byte(body))
+ task.Consume()
+ }
+ // 销毁信息
+ _ = cache2.Cache.ZRem(config.RedisKeyForTaskQueue, cache)
+ _ = cache2.Cache.HDel(config.RedisKeyForTaskQueueBody, cache...)
+ }
+ // 每秒执行一次
+ time.Sleep(time.Second)
+ }
+ })
+}
+
+func NewTaskQueue() *TaskQueue {
+ return &TaskQueue{}
+}
diff --git a/task/task.go b/task/task.go
new file mode 100644
index 0000000..7b8f62d
--- /dev/null
+++ b/task/task.go
@@ -0,0 +1,62 @@
+package task
+
+import (
+ "Edu/utils"
+ "encoding/json"
+ "fmt"
+ "time"
+)
+
+type ITask interface {
+ MarshalBinary() ([]byte, error)
+ UnmarshalBinary(data []byte) error
+ Handle() error
+}
+
+type Task struct {
+ ID string `json:"id"` // Job唯一标识
+ Topic string `json:"topic"` // Job类型
+ Delay int64 `json:"delay"` // Job需要延迟的时间, 单位:秒
+ Body ITask `json:"body"` // Job的内容,供消费者做具体的业务处理
+}
+
+type TaskHandle func(topic string, delay int64, body ITask) *Task
+
+func (this *Task) MarshalBinary() ([]byte, error) {
+ return json.Marshal(this)
+}
+
+func (this *Task) UnmarshalBinary(data []byte) error {
+ return utils.FromJSONBytes(data, this)
+}
+
+func (this *Task) setID() string {
+ return utils.Sha1String(fmt.Sprintf("%s%d%s", this.Topic, time.Now().UnixNano(), utils.GetRandomCode(6)))
+}
+
+func (this *Task) DelayUnix() int64 {
+ return time.Now().Unix() + this.Delay
+}
+
+func (this *Task) Push() {
+ TaskListenEvent.Join(this)
+}
+
+// Consume 消费
+func (this *Task) Consume() {
+ TaskListenEvent.Quit(this)
+}
+
+func (this *Task) Handle() error {
+ // 处理各种方法
+ this.Body.(*Order).Handle()
+ return nil
+}
+
+func NewTask() TaskHandle {
+ return func(topic string, delay int64, body ITask) *Task {
+ task := &Task{Topic: topic, Delay: delay, Body: body}
+ task.ID = task.setID()
+ return task
+ }
+}
diff --git a/tools/init.go b/tools/init.go
new file mode 100644
index 0000000..2edf7e7
--- /dev/null
+++ b/tools/init.go
@@ -0,0 +1,13 @@
+package tools
+
+import (
+ "Edu/tools/ip"
+)
+
+func initIP() {
+ _ = ip.Load("./file/ip_chunzhen.txt")
+}
+
+func Init() {
+ initIP()
+}
diff --git a/tools/ip/ip_data.go b/tools/ip/ip_data.go
new file mode 100644
index 0000000..82a2855
--- /dev/null
+++ b/tools/ip/ip_data.go
@@ -0,0 +1,102 @@
+package ip
+
+import (
+ "bufio"
+ "bytes"
+ "encoding/binary"
+ "io"
+ "net"
+ "strconv"
+ "strings"
+)
+
+type IpData []*IpRange
+
+func NewIpData() *IpData {
+ return &IpData{}
+}
+
+//TODO 初始化后对数据做排序
+func (id *IpData) Load(r io.Reader) error {
+ scanner := bufio.NewScanner(r)
+
+ for scanner.Scan() {
+ line := scanner.Text()
+ item := strings.SplitN(line, "\t", ipRangeFieldCount)
+ if len(item) != ipRangeFieldCount {
+ continue
+ }
+
+ begin, _ := strconv.Atoi(item[0])
+ end, _ := strconv.Atoi(item[1])
+ if begin > end {
+ continue
+ }
+
+ ir := &IpRange{
+ Begin: uint32(begin),
+ End: uint32(end),
+ Data: []byte(item[2]),
+ }
+
+ *id = append(*id, ir)
+ }
+
+ return scanner.Err()
+}
+
+func (id *IpData) ReLoad(r io.Reader) error {
+ nId := NewIpData()
+ err := nId.Load(r)
+ if err != nil {
+ return err
+ }
+
+ *id = *nId
+ return nil
+}
+
+func (id *IpData) Length() int {
+ return len(*id)
+}
+
+func (id *IpData) Find(ip string) (*IpRange, error) {
+ ir, err := id.getIpRange(ip)
+ if err != nil {
+ return nil, err
+ }
+
+ return ir, nil
+}
+
+func (id *IpData) getIpRange(ip string) (*IpRange, error) {
+ var low, high int = 0, (id.Length() - 1)
+
+ ipdt := *id
+ il := ip2Long(ip)
+ if il <= 0 {
+ return nil, ErrorIpRangeNotFound
+ }
+
+ for low <= high {
+ var middle int = (high-low)/2 + low
+
+ ir := ipdt[middle]
+
+ if il >= ir.Begin && il <= ir.End {
+ return ir, nil
+ } else if il < ir.Begin {
+ high = middle - 1
+ } else {
+ low = middle + 1
+ }
+ }
+
+ return nil, ErrorIpRangeNotFound
+}
+
+func ip2Long(ip string) uint32 {
+ var long uint32
+ binary.Read(bytes.NewBuffer(net.ParseIP(ip).To4()), binary.BigEndian, &long)
+ return long
+}
diff --git a/tools/ip/ip_range.go b/tools/ip/ip_range.go
new file mode 100644
index 0000000..ca7f2c3
--- /dev/null
+++ b/tools/ip/ip_range.go
@@ -0,0 +1,17 @@
+package ip
+
+import (
+ "errors"
+)
+
+const (
+ ipRangeFieldCount = 3
+)
+
+var ErrorIpRangeNotFound = errors.New("ip range not found")
+
+type IpRange struct {
+ Begin uint32
+ End uint32
+ Data []byte
+}
diff --git a/tools/ip/ipquery.go b/tools/ip/ipquery.go
new file mode 100644
index 0000000..05bcb56
--- /dev/null
+++ b/tools/ip/ipquery.go
@@ -0,0 +1,41 @@
+package ip
+
+import (
+ "os"
+)
+
+var defaultIpData *IpData
+
+func init() {
+ defaultIpData = NewIpData()
+}
+
+func Load(df string) error {
+ reader, err := os.Open(df)
+
+ if err != nil {
+ return err
+ }
+ return defaultIpData.Load(reader)
+}
+
+func ReLoad(df string) error {
+ reader, err := os.Open(df)
+ if err != nil {
+ return err
+ }
+ return defaultIpData.ReLoad(reader)
+}
+
+func Length() int {
+ return defaultIpData.Length()
+}
+
+func Find(ip string) ([]byte, error) {
+ ir, err := defaultIpData.Find(ip)
+ if err != nil {
+ return nil, err
+ } else {
+ return ir.Data, nil
+ }
+}
diff --git a/utils/array.go b/utils/array.go
new file mode 100644
index 0000000..30e3226
--- /dev/null
+++ b/utils/array.go
@@ -0,0 +1,51 @@
+package utils
+
+import (
+ "fmt"
+ "reflect"
+)
+
+func InArray(search, needle interface{}) bool {
+ val := reflect.ValueOf(needle)
+
+ kind := val.Kind()
+
+ if kind == reflect.Slice || kind == reflect.Array {
+ for i := 0; i < val.Len(); i++ {
+ if val.Index(i).Interface() == search {
+ return true
+ }
+ }
+ }
+ return false
+}
+
+func ArrayFlip(src interface{}) interface{} {
+ val := reflect.ValueOf(src)
+
+ kind := val.Kind()
+
+ out := make(map[interface{}]interface{}, 0)
+
+ if kind == reflect.Slice || kind == reflect.Array || kind == reflect.Map {
+ for i := 0; i < val.Len(); i++ {
+ fmt.Printf("val.Field():%v\n", val.Index(i).MapKeys())
+ }
+ }
+ return out
+}
+
+func ArrayStrings(src interface{}) []string {
+ out := make([]string, 0)
+
+ val := reflect.ValueOf(src)
+
+ kind := val.Kind()
+
+ if kind == reflect.Slice || kind == reflect.Array {
+ for i := 0; i < val.Len(); i++ {
+ out = append(out, fmt.Sprintf("%v", val.Index(i).Interface()))
+ }
+ }
+ return out
+}
diff --git a/utils/array_test.go b/utils/array_test.go
new file mode 100644
index 0000000..2153867
--- /dev/null
+++ b/utils/array_test.go
@@ -0,0 +1,31 @@
+package utils
+
+import (
+ "reflect"
+ "testing"
+)
+
+const (
+ a = 0x00001
+ b = 0x00010
+ c = 0x00100
+)
+
+func TestArrayFlip(t *testing.T) {
+ //flip := []uint64{1, 2, 3, 4}
+ //out := ArrayFlip(flip)
+ //t.Logf("out:%v\n", out)
+
+ d := a & b & c
+ t.Log(d)
+
+}
+
+func TestArrayStrings(t *testing.T) {
+ a := []uint64{1, 2, 3, 4, 5}
+ t.Log(a)
+ t.Log(reflect.TypeOf(a).String())
+ b := ArrayStrings(a)
+ t.Log(b)
+ t.Log(reflect.TypeOf(b).String())
+}
diff --git a/utils/bit_calc.go b/utils/bit_calc.go
new file mode 100644
index 0000000..63d72bb
--- /dev/null
+++ b/utils/bit_calc.go
@@ -0,0 +1,9 @@
+package utils
+
+// Exchange 位置交换
+func Exchange(a, b int) (int, int) {
+ a = a ^ b
+ b = a ^ b
+ a = a ^ b
+ return a, b
+}
diff --git a/utils/bit_calc_test.go b/utils/bit_calc_test.go
new file mode 100644
index 0000000..228d783
--- /dev/null
+++ b/utils/bit_calc_test.go
@@ -0,0 +1,83 @@
+package utils
+
+import (
+ "bufio"
+ "io/ioutil"
+ "os"
+ "strconv"
+ "testing"
+)
+
+func converToBianry(n int) string {
+ result := ""
+ for ; n > 0; n /= 2 {
+ lsb := n % 2
+ result = strconv.Itoa(lsb) + result
+ }
+ return result
+}
+
+// 1,2,4
+func TestExchange(t *testing.T) {
+ for i := 0; i < 10; i++ {
+ //t.Log(1 << uint(i))
+ }
+
+ //t.Log(0b00000000100)
+ a := 1
+ b := 1 << 1
+ c := 1 << 2
+ t.Log(a)
+ t.Log(b)
+ t.Log(c)
+
+ d := a | b | c
+ t.Log(d)
+
+ t.Log(d & a)
+ t.Log(d & b)
+ t.Log(d & c)
+}
+
+func TestAnyToByte(t *testing.T) {
+ src := []int{1}
+
+ mark := 0
+
+ for i := 0; i < len(src); i++ {
+ mark = mark | src[i]
+ }
+ t.Log(mark)
+}
+
+func TestFromJSONFile(t *testing.T) {
+ file := "FWBAT-GX-A13-V310.bin"
+ f, err := os.Open(file)
+ if err != nil {
+ t.Log(err)
+ return
+ }
+ defer f.Close()
+ content, err := ioutil.ReadAll(f)
+
+ if err != nil {
+ t.Log(err)
+ return
+ }
+ t.Log(content)
+ t.Log(len(content))
+
+ inputReader := bufio.NewReader(f)
+ s, _, _ := inputReader.ReadLine()
+
+ t.Log(s)
+ t.Log(len(s))
+ //t.Log(bufio.NewReader(f))
+ //for {
+ // inputString, readerError := inputReader.ReadString('\n') //我们将inputReader里面的字符串按行进行读取。
+ // if readerError == io.EOF {
+ // return
+ // }
+ // t.Log(inputString)
+ //}
+}
diff --git a/utils/catch.go b/utils/catch.go
new file mode 100644
index 0000000..7520382
--- /dev/null
+++ b/utils/catch.go
@@ -0,0 +1,13 @@
+package utils
+
+import "fmt"
+
+func TryCatch(f func()) {
+ defer func() {
+ if err := recover(); err != nil {
+ err = fmt.Errorf("internal error: %v", err)
+ fmt.Printf("TryCatch Error:%v\n", err)
+ }
+ }()
+ f()
+}
diff --git a/utils/convert.go b/utils/convert.go
new file mode 100644
index 0000000..1831c40
--- /dev/null
+++ b/utils/convert.go
@@ -0,0 +1,89 @@
+package utils
+
+import (
+ "reflect"
+ "strings"
+)
+
+var (
+ // types 数据结构类型
+ types = []string{"string", "int64", "int", "uint", "uint64", "byte"}
+)
+
+// ConvertTypes 需转换的类型
+type ConvertTypes struct {
+ String, Int64, Int, Uint, Uint64, Byte bool
+}
+
+// TypeConvert type mutual convert
+// result -- interface.(type)
+func (c *ConvertTypes) TypeConvert(from interface{}) interface{} {
+
+ fType := reflect.TypeOf(from)
+
+ val := func(r reflect.Type) interface{} {
+
+ return nil
+
+ }(fType)
+
+ return val
+}
+
+// MapToStruct map to struct
+// key is struct filedName
+func MapToStruct(m map[string]interface{}, s interface{}) {
+ for k, v := range m {
+
+ tRef := reflect.TypeOf(s).Elem()
+
+ fieldNum := tRef.NumField()
+
+ for i := 0; i < fieldNum; i++ {
+ // 匹配结构字段名称
+ if strings.ToLower(k) != strings.ToLower(tRef.Field(i).Name) {
+ continue
+ }
+
+ vRef := reflect.ValueOf(s).Elem().FieldByName(tRef.Field(i).Name)
+
+ if !vRef.CanSet() {
+ continue
+ }
+
+ switch vRef.Type().String() {
+ case "string":
+ vRef.SetString(v.(string))
+ break
+ case "int64":
+ vRef.SetInt(v.(int64))
+ break
+ case "int":
+ switch reflect.TypeOf(v).String() {
+ case "float64":
+ vRef.SetInt(int64(v.(float64)))
+ break
+ case "int":
+ vRef.SetInt(int64(v.(int)))
+ break
+ }
+ break
+ case "bool":
+ vRef.SetBool(v.(bool))
+ break
+ }
+ }
+ }
+}
+
+// StructToMap struct to map
+func StructToMap(s interface{}, m map[string]interface{}) {
+ tRef := reflect.TypeOf(s).Elem()
+ vRef := reflect.ValueOf(s).Elem()
+
+ fieldNum := tRef.NumField()
+
+ for index := 0; index < fieldNum; index++ {
+ m[tRef.Field(index).Name] = vRef.FieldByName(tRef.Field(index).Name).Interface()
+ }
+}
diff --git a/utils/encrypt.go b/utils/encrypt.go
new file mode 100644
index 0000000..3e85253
--- /dev/null
+++ b/utils/encrypt.go
@@ -0,0 +1,138 @@
+package utils
+
+import (
+ "bytes"
+ "crypto/aes"
+ "crypto/cipher"
+ "crypto/md5"
+ "crypto/sha1"
+ "crypto/sha256"
+ "crypto/sha512"
+ "encoding/base64"
+ "encoding/hex"
+ "github.com/speps/go-hashids"
+ "strings"
+
+ "golang.org/x/crypto/bcrypt"
+)
+
+// salt 盐值
+const salt = "CHeF6AC392"
+
+func Base64Encode(src string) string {
+ return base64.StdEncoding.EncodeToString([]byte(src))
+}
+
+func Base64Decode(src string) []byte {
+ _bytes, _ := base64.StdEncoding.DecodeString(src)
+ return _bytes
+}
+
+// Md5String
+func Md5String(s string, salt ...string) string {
+ h := md5.New()
+ if len(salt) > 0 {
+ s += strings.Join(salt, "")
+ }
+ h.Write([]byte(s))
+ return hex.EncodeToString(h.Sum(nil))
+}
+
+// Sha1String
+func Sha1String(s string) string {
+ h := sha1.New()
+ h.Write([]byte(s))
+ return hex.EncodeToString(h.Sum(nil))
+}
+
+// Sha256String
+func Sha256String(s string) string {
+ h := sha256.New()
+ h.Write([]byte(s))
+ return hex.EncodeToString(h.Sum(nil))
+}
+
+// Sha512String
+func Sha512String(s string) string {
+ h := sha512.New()
+ h.Write([]byte(s))
+ return hex.EncodeToString(h.Sum(nil))
+}
+
+func HashString(s []byte) string {
+ hash, _ := bcrypt.GenerateFromPassword(s, bcrypt.DefaultCost)
+ return string(hash)
+}
+
+func HashCompare(src, compare []byte) bool {
+ return bcrypt.CompareHashAndPassword(src, compare) == nil
+}
+
+// HASHIDEncode 混淆
+func HASHIDEncode(src int) string {
+ hd := hashids.NewData()
+ hd.Salt = salt
+ hd.MinLength = 6
+ h := hashids.NewWithData(hd)
+ e, _ := h.Encode([]int{src})
+ return e
+}
+
+// HASHIDDecode 还原混淆
+func HASHIDDecode(src string) int {
+ hd := hashids.NewData()
+ hd.Salt = salt
+ h := hashids.NewWithData(hd)
+ e, _ := h.DecodeWithError(src)
+ return e[0]
+}
+
+// Padding 对明文进行填充
+func Padding(plainText []byte, blockSize int) []byte {
+ n := blockSize - len(plainText)%blockSize
+ temp := bytes.Repeat([]byte{byte(n)}, n)
+ plainText = append(plainText, temp...)
+ return plainText
+}
+
+// UnPadding 对密文删除填充
+func UnPadding(cipherText []byte) []byte {
+ end := cipherText[len(cipherText)-1]
+ cipherText = cipherText[:len(cipherText)-int(end)]
+ return cipherText
+}
+
+// AESCBCEncrypt AEC加密(CBC模式)
+func AESCBCEncrypt(plainText, key, iv []byte) ([]byte, error) {
+ //指定加密算法,返回一个AES算法的Block接口对象
+ block, err := aes.NewCipher(key)
+ if err != nil {
+ return nil, err
+ }
+ //进行填充
+ plainText = Padding(plainText, block.BlockSize())
+ //指定分组模式,返回一个BlockMode接口对象
+ blockMode := cipher.NewCBCEncrypter(block, iv)
+ //加密连续数据库
+ cipherText := make([]byte, len(plainText))
+ blockMode.CryptBlocks(cipherText, plainText)
+ //返回密文
+ return cipherText, nil
+}
+
+// AESCBCDecrypt AEC解密(CBC模式)
+func AESCBCDecrypt(cipherText, key, iv []byte) ([]byte, error) {
+ //指定解密算法,返回一个AES算法的Block接口对象
+ block, err := aes.NewCipher(key)
+ if err != nil {
+ return nil, err
+ }
+ //指定分组模式,返回一个BlockMode接口对象
+ blockMode := cipher.NewCBCDecrypter(block, iv)
+ //解密
+ plainText := make([]byte, len(cipherText))
+ blockMode.CryptBlocks(plainText, cipherText)
+ //删除填充
+ plainText = UnPadding(plainText)
+ return plainText, nil
+}
diff --git a/utils/encrypt_test.go b/utils/encrypt_test.go
new file mode 100644
index 0000000..5aade2e
--- /dev/null
+++ b/utils/encrypt_test.go
@@ -0,0 +1,9 @@
+package utils
+
+import "testing"
+
+func TestSha256String(t *testing.T) {
+ //t.Log(Md5String("9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05"))
+ t.Log(HASHIDEncode(123))
+ t.Log(HASHIDDecode("lV5OBJ"))
+}
diff --git a/utils/file.go b/utils/file.go
new file mode 100644
index 0000000..f28464b
--- /dev/null
+++ b/utils/file.go
@@ -0,0 +1,61 @@
+package utils
+
+import (
+ "fmt"
+ "os"
+)
+
+func Open(name string) (f *os.File, err error) {
+ _, err = os.Stat(name)
+
+ if os.IsNotExist(err) {
+ return os.OpenFile(name, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
+ }
+ if err != nil {
+ return nil, err
+ }
+ return nil, fmt.Errorf("file %s already exists", name)
+}
+
+func PathExists(path string) (bool, error) {
+ _, err := os.Stat(path)
+
+ if err == nil {
+ return true, nil
+ }
+ if os.IsNotExist(err) {
+ return false, nil
+ }
+ return false, err
+}
+
+func IsDir(path string) bool {
+ s, err := os.Stat(path)
+
+ if err != nil {
+ return false
+ }
+ return s.IsDir()
+}
+
+func Mkdir(path string) error {
+ return os.Mkdir(path, os.ModePerm)
+}
+
+func MkdirAll(path string) error {
+ return os.MkdirAll(path, os.ModePerm)
+}
+
+func PrepareOutput(path string) error {
+ fi, err := os.Stat(path)
+
+ if err != nil {
+ if os.IsExist(err) && !fi.IsDir() {
+ return err
+ }
+ if os.IsNotExist(err) {
+ err = os.MkdirAll(path, 0777)
+ }
+ }
+ return err
+}
diff --git a/utils/json.go b/utils/json.go
new file mode 100644
index 0000000..87dc465
--- /dev/null
+++ b/utils/json.go
@@ -0,0 +1,83 @@
+package utils
+
+import (
+ "bufio"
+ "encoding/json"
+ "errors"
+ "io"
+ "os"
+)
+
+// AnyToJSON ToJson
+func AnyToJSON(any interface{}) string {
+ bytes, _ := json.Marshal(any)
+ return string(bytes)
+}
+
+// AnyToByte ToByte
+func AnyToByte(any interface{}) []byte {
+ bytes, _ := json.Marshal(any)
+ return bytes
+}
+
+// FromJSON get value from JSON string
+func FromJSON(data string, v interface{}) error {
+ if data == "" {
+ return errors.New("data nil")
+ }
+
+ if err := json.Unmarshal([]byte(data), v); err != nil {
+ return err
+ }
+ return nil
+}
+
+// FromJSONToMap get mapvalue from JSON string
+func FromJSONToMap(data string) map[string]interface{} {
+ var jsonBody map[string]interface{}
+ //解析 body
+ if len(data) > 0 {
+ FromJSON(data, &jsonBody)
+ } else {
+ jsonBody = make(map[string]interface{}, 0)
+ }
+ return jsonBody
+}
+
+// FromJSONBytes get value from JSON bytes
+func FromJSONBytes(data []byte, v interface{}) error {
+ if len(data) <= 0 {
+ return errors.New("data nil")
+ }
+
+ if err := json.Unmarshal(data, v); err != nil {
+ return err
+ }
+ return nil
+}
+
+// FromJSONReader get value from JSON Reader
+func FromJSONReader(data io.Reader, v interface{}) error {
+ if data == nil {
+ return errors.New("jsonFile nail")
+ }
+
+ jsonDecoder := json.NewDecoder(data)
+ return jsonDecoder.Decode(v)
+}
+
+// FromJSONFile get value from JSON file
+func FromJSONFile(jsonFile string, v interface{}) error {
+ if len(jsonFile) <= 0 {
+ return errors.New("jsonFile nail")
+ }
+
+ file, err := os.Open(jsonFile)
+ if err != nil {
+ return err
+ }
+ defer file.Close()
+
+ jsonDecoder := json.NewDecoder(bufio.NewReader(file))
+ return jsonDecoder.Decode(v)
+}
diff --git a/utils/jwt.go b/utils/jwt.go
new file mode 100644
index 0000000..bbb78e3
--- /dev/null
+++ b/utils/jwt.go
@@ -0,0 +1,45 @@
+package utils
+
+import (
+ "fmt"
+ "time"
+
+ "github.com/dgrijalva/jwt-go"
+)
+
+const jwtKey = "abc123ABC"
+
+// JWTEncrypt 加密
+func JWTEncrypt(effectTimes int, param ...map[string]interface{}) string {
+ token := jwt.New(jwt.SigningMethodHS256)
+ claims := make(jwt.MapClaims, 0)
+ claims["exp"] = fmt.Sprintf("%d", time.Now().Add(time.Second*time.Duration(effectTimes)).Unix())
+ claims["iat"] = fmt.Sprintf("%d", time.Now().Unix())
+
+ if len(param) > 0 {
+ for _, val := range param {
+ for k, v := range val {
+ claims[k] = v
+ }
+ }
+ }
+ token.Claims = claims
+ tokenString, _ := token.SignedString([]byte(jwtKey))
+ return tokenString
+}
+
+// JWTDecrypt 解密
+func JWTDecrypt(tokenString string) jwt.MapClaims {
+ token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
+ return []byte(jwtKey), nil
+ })
+ if err != nil {
+ return nil
+ }
+ claims, ok := token.Claims.(jwt.MapClaims)
+
+ if !ok {
+ return nil
+ }
+ return claims
+}
diff --git a/utils/rand.go b/utils/rand.go
new file mode 100644
index 0000000..3fee319
--- /dev/null
+++ b/utils/rand.go
@@ -0,0 +1,42 @@
+package utils
+
+import (
+ "fmt"
+ "math/rand"
+ "strings"
+ "time"
+
+ uuid "github.com/satori/go.uuid"
+)
+
+const (
+ str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+)
+
+func GetUUID() string {
+ return uuid.NewV4().String()
+}
+
+func GetRandomCode(length int) string {
+ rand.Seed(time.Now().Unix())
+
+ code := make([]string, 0)
+
+ for i := 0; i < length; i++ {
+ code = append(code, fmt.Sprintf("%d", rand.Intn(10)))
+ }
+ return strings.Join(code, "")
+}
+
+func GetRandomString(length int) string {
+ bytes := []byte(str)
+
+ result := make([]byte, 0)
+
+ r := rand.New(rand.NewSource(time.Now().UnixNano()))
+
+ for i := 0; i < length; i++ {
+ result = append(result, bytes[r.Intn(len(bytes))])
+ }
+ return string(result)
+}
diff --git a/utils/reflect.go b/utils/reflect.go
new file mode 100644
index 0000000..4dd0cc9
--- /dev/null
+++ b/utils/reflect.go
@@ -0,0 +1,14 @@
+package utils
+
+import (
+ "bytes"
+ "encoding/gob"
+)
+
+func DeepCopy(dst, src interface{}) error {
+ var buf bytes.Buffer
+ if err := gob.NewEncoder(&buf).Encode(src); err != nil {
+ return err
+ }
+ return gob.NewDecoder(bytes.NewBuffer(buf.Bytes())).Decode(dst)
+}
diff --git a/utils/regexp.go b/utils/regexp.go
new file mode 100644
index 0000000..84d1821
--- /dev/null
+++ b/utils/regexp.go
@@ -0,0 +1,45 @@
+package utils
+
+import (
+ "regexp"
+)
+
+func ValidateMobile(mobile string) bool {
+ reg := regexp.MustCompile("^1[3|4|5|6|7|8|9][0-9]\\d{8}$")
+ return reg.MatchString(mobile)
+}
+
+func ValidateEmail(email string) bool {
+ reg := regexp.MustCompile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$")
+ return reg.MatchString(email)
+}
+
+func ValidateUrl(url string) {
+ //reg := regexp.MustCompile("^([hH][tT]{2}[pP]:|||[hH][tT]{2}[pP][sS]:|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$")
+}
+
+func ValidateIDCard(obj string) bool {
+ reg := regexp.MustCompile("^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$")
+ return reg.MatchString(obj)
+
+}
+
+func ValidateIP(ip string) bool {
+ reg := regexp.MustCompile("^((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}$")
+ return reg.MatchString(ip)
+}
+
+func ValidateCompile(obj, compile string) bool {
+ reg := regexp.MustCompile(compile)
+ return reg.MatchString(obj)
+}
+
+func ReplaceAllCompile(obj, compile, replace string) string {
+ reg := regexp.MustCompile(compile)
+ return reg.ReplaceAllString(obj, replace)
+}
+
+func MatchString(pattern string, s string) bool {
+ status, _ := regexp.MatchString(pattern, s)
+ return status
+}
diff --git a/utils/regexp_test.go b/utils/regexp_test.go
new file mode 100644
index 0000000..6dcd016
--- /dev/null
+++ b/utils/regexp_test.go
@@ -0,0 +1,47 @@
+package utils
+
+import (
+ "testing"
+)
+
+func TestReplaceCompile(t *testing.T) {
+ src := "12312321321"
+
+ t.Log(src)
+
+ compile := "[/]+"
+ src = ReplaceAllCompile(src, compile, "/")
+ t.Log(src)
+
+ compile = "(^[\\w])([\\w/]*)([\\w])$"
+ //compile = "(^[\\w])"
+
+ //compile = "^[\\w]" +
+ // "([\\w*])" +
+ // "[\\w]$"
+ status := ValidateCompile(src, compile)
+ t.Log(status)
+
+ //compile := "user.+\\z"
+ //src = ReplaceAllCompile(src, compile, "user")
+ //t.Log(src)
+
+ //compile = "^\\w{0,50}$"
+ //status = ValidateCompile(src, compile)
+ //t.Log(status)
+ //
+ ////支持中文、大小写字母、日文、数字、短划线、下划线、斜杠和小数点,必须以中文、英文或数字开头,不超过 30 个字符
+ //compile = "(^[a-zA-Z0-9\u4e00-\u9fa5])([a-zA-Z0-9_\u4e00-\u9fa5-_/.]*){0,30}$"
+ //status = ValidateCompile(src, compile)
+ //t.Logf("文本检测:%v\n", status)
+}
+
+func TestValidateCompile(t *testing.T) {
+ src := "2134"
+
+ t.Log(src)
+
+ compile := "^[\\w-.:]{4,32}$"
+ status := ValidateCompile(src, compile)
+ t.Log(status)
+}
diff --git a/utils/request.go b/utils/request.go
new file mode 100644
index 0000000..bbaa16f
--- /dev/null
+++ b/utils/request.go
@@ -0,0 +1,118 @@
+package utils
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "strings"
+)
+
+type (
+ // Headers 消息头
+ Headers struct {
+ UserAgent string
+ ContentType string
+ Cookies map[string]string
+ Others map[string]string
+ }
+
+ // Method 请求方式
+ Method string
+
+ // Client
+ Client struct {
+ Url string
+ Method Method
+ Params map[string]interface{}
+ }
+)
+
+const (
+ MethodForGet Method = "GET"
+ MethodForPost Method = "POST"
+
+ DefaultUserAgent string = "Mozilla/5.0 (SF) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.6.6666.66 Safari/537.36"
+)
+
+// RequestBodyFormat 请求消息内容格式
+type RequestBodyFormat int
+
+const (
+ RequestBodyFormatForFormData RequestBodyFormat = iota + 1
+ RequestBodyFormatForXWWWFormUrlencoded
+ RequestBodyFormatForRaw
+)
+
+const (
+ RequestContentTypeForFormData string = "application/form-data"
+ RequestContentTypeForXWWWFormUrlencoded string = "application/x-www-form-urlencoded"
+)
+
+// Request 发起请求
+func (this *Client) Request(format RequestBodyFormat, headers ...Headers) ([]byte, error) {
+ client := new(http.Client)
+
+ var reqBody io.Reader
+
+ if this.Method == MethodForGet {
+ _params := make([]string, 0)
+
+ for k, v := range this.Params {
+ _params = append(_params, fmt.Sprintf("%s=%v", k, v))
+ }
+ this.Url += "?" + strings.Join(_params, "&")
+ } else {
+ if format == RequestBodyFormatForFormData || format == RequestBodyFormatForXWWWFormUrlencoded {
+ _params := make([]string, 0)
+ for k, v := range this.Params {
+ _params = append(_params, fmt.Sprintf("%s=%v", k, v))
+ }
+ reqBody = strings.NewReader(strings.Join(_params, "&"))
+ } else if format == RequestBodyFormatForRaw {
+ _bytes, _ := json.Marshal(this.Params)
+ reqBody = bytes.NewReader(_bytes)
+ }
+ }
+ req, err := http.NewRequest(string(this.Method), this.Url, reqBody)
+
+ if err != nil {
+ return nil, err
+ }
+ for _, v := range headers {
+ if v.UserAgent != "" {
+ req.Header.Add("User-Agent", v.UserAgent)
+ }
+ if v.ContentType != "" {
+ req.Header.Add("Content-Type", v.ContentType)
+ }
+ if len(v.Cookies) > 0 {
+ for key, val := range v.Cookies {
+ req.AddCookie(&http.Cookie{Name: key, Value: val})
+ }
+ }
+ if len(v.Others) > 0 {
+ for key, val := range v.Others {
+ req.Header.Add(key, val)
+ }
+ }
+ }
+ resp := new(http.Response)
+
+ if resp, err = client.Do(req); err != nil {
+ return nil, err
+ }
+ bytes, err := ioutil.ReadAll(resp.Body)
+ defer resp.Body.Close()
+
+ return bytes, err
+}
+
+// NewClient
+func NewClient(url string, method Method, params map[string]interface{}) *Client {
+ return &Client{
+ Url: url, Method: method, Params: params,
+ }
+}
diff --git a/utils/request_test.go b/utils/request_test.go
new file mode 100644
index 0000000..02727a8
--- /dev/null
+++ b/utils/request_test.go
@@ -0,0 +1,266 @@
+package utils
+
+import (
+ "encoding/binary"
+ "log"
+ "os"
+ "testing"
+)
+
+type (
+ // BaiDuError 错误提示
+ BaiDuError struct {
+ Error string `json:"error"`
+ ErrorDescription string `json:"error_description"`
+ }
+ // BaiDuAccessToken AccessToken信息
+ BaiDuAccessToken struct {
+ RefreshToken string `json:"refresh_token"`
+ ExpiresIn int `json:"expires_in"`
+ Scope string `json:"scope"`
+ SessionKey string `json:"session_key"`
+ AccessToken string `json:"access_token"`
+ SessionSecret string `json:"session_secret"`
+ BaiDuError
+ }
+ // BaiDuSpeechQuick SpeechQuick信息
+ BaiDuSpeechQuick struct {
+ ErrNo int `json:"err_no"`
+ ErrMsg string `json:"err_msg"`
+ SN string `json:"sn"`
+ Result []string `json:"result"`
+ }
+ // BaiDuRobotDialogue 机器人对话
+ BaiDuRobotDialogue struct {
+ ErrorCode int `json:"error_code"`
+ ErrorMsg string `json:"error_msg"`
+ Result struct {
+ Version string `json:"version"`
+ ServiceID string `json:"service_id"`
+ LogID string `json:"log_id"`
+ InteractionID string `json:"interaction_id"`
+ Response struct {
+ Status int `json:"status"`
+ Msg string `json:"msg"`
+ ActionList []struct {
+ Confidence float64 `json:"confidence"`
+ ActionID string `json:"action_id"`
+ Say string `json:"say"`
+ CustomReply string `json:"custom_reply"`
+ Type string `json:"type"`
+ } `json:"action_list"`
+ Schema struct {
+ Confidence float64 `json:"confidence"`
+ Intent string `json:"intent"`
+ IntentConfidence float64 `json:"intent_confidence"`
+ Slots []struct {
+ Confidence float64 `json:"confidence"`
+ Begin int `json:"begin"`
+ Length int `json:"length"`
+ OriginalWord string `json:"original_word"`
+ NormalizedWord string `json:"normalized_word"`
+ WordType string `json:"word_type"`
+ Name string `json:"name"`
+ SessionOffset string `json:"session_offset"`
+ MergeMethod string `json:"merge_method"`
+ } `json:"slots"`
+ } `json:"schema"`
+ } `json:"response"`
+ } `json:"result"`
+ }
+)
+
+const (
+ baiDuClientID string = "Sy0tLT7bHWE2RhollVOqelHq"
+ baiDuClientSecret string = "jSr0a2Isaivi1yvgk2TXlB7tqg21Gf1m"
+ //baiDuClientID string = "MDNsII2jkUtbF729GQOZt7FS"
+ //baiDuClientSecret string = "0vWCVCLsbWHMSH1wjvxaDq4VmvCZM2O9"
+
+ // baiDuRequestURLForAccessToken 获取token地址
+ baiDuRequestURLForAccessToken string = "https://aip.baidubce.com/oauth/2.0/token"
+ // baiDuRequestURLForVoiceQuick 语音识别极速版
+ baiDuRequestURLForVoiceQuick string = "https://vop.baidu.com/pro_api"
+ // baiDuRequestURLForRobotDialogue 语音机器人对话
+ baiDuRequestURLForRobotDialogue string = "https://aip.baidubce.com/rpc/2.0/unit/bot/chat"
+ //baiDuRequestURLForRobotDialogue string = "https://aip.baidubce.com/rpc/2.0/unit/service/chat"
+)
+
+func TestNewClient(t *testing.T) {
+ //file := "../upload/20210624/16k1.pcm"
+ //
+ client2 := NewClient(baiDuRequestURLForAccessToken, MethodForPost, map[string]interface{}{
+ "grant_type": "client_credentials", "client_id": baiDuClientID, "client_secret": baiDuClientSecret,
+ })
+ resp2, err := client2.Request(RequestBodyFormatForFormData)
+
+ if err != nil {
+ t.Log(err)
+ return
+ }
+ response := new(BaiDuAccessToken)
+
+ _ = FromJSONBytes(resp2, response)
+
+ if response.Error != "" {
+ t.Logf("获取百度AccessToken错误:%v - %v", response.Error, response.ErrorDescription)
+ return
+ }
+ //t.Log(response.AccessToken)
+ //
+ //reader, err := os.OpenFile(file, os.O_RDONLY, 0666)
+ //
+ //if err != nil {
+ // t.Log(err)
+ // return
+ //}
+ //defer reader.Close()
+ //
+ //content, _ := ioutil.ReadAll(reader)
+ //
+ //cuid := ""
+ //
+ //netitfs, err := net.Interfaces()
+ //
+ //if err != nil {
+ // cuid = "anonymous_sqzn"
+ //} else {
+ // for _, itf := range netitfs {
+ // if cuid = itf.HardwareAddr.String(); len(cuid) > 0 {
+ // break
+ // }
+ // }
+ //}
+ //t.Log(cuid)
+ //t.Log(base64.StdEncoding.EncodeToString(content))
+ //t.Log(fmt.Sprintf("%d", len(content)))
+ //
+ //_params := map[string]interface{}{
+ // "format": file[len(file)-3:],
+ // "rate": 16000,
+ // "dev_pid": 1537,
+ // "channel": 1,
+ // "token": "24.1f876b06d070d7403c90832dddb813cb.2592000.1627110943.282335-24431674",
+ // "cuid": cuid,
+ // "speech": base64.StdEncoding.EncodeToString(content),
+ // "len": len(content),
+ //}
+ //_json, _ := json.Marshal(_params)
+ //
+ //req, err := http.NewRequest("GET", "http://vop.baidu.com/server_api", bytes.NewBuffer(_json))
+ //
+ //if err != nil {
+ // t.Log(err)
+ // return
+ //}
+ //resp := new(http.Response)
+ //
+ //client := new(http.Client)
+ //
+ //if resp, err = client.Do(req); err != nil {
+ // t.Log(err)
+ // return
+ //}
+ //bytes, err := ioutil.ReadAll(resp.Body)
+ //defer resp.Body.Close()
+ //
+ //response1 := new(BaiDuSpeechQuick)
+ //
+ //_ = FromJSONBytes(bytes, response1)
+ //
+ //t.Logf("resp:%v\n", AnyToJSON(response1))
+
+ serviceID := "1101579"
+
+ params2 := map[string]interface{}{
+ "version": "2.0",
+ //"service_id": serviceID,
+ "bot_id": serviceID,
+ "log_id": Md5String(AnyToJSON(2040256374931197952), serviceID),
+ "session_id": Sha256String(AnyToJSON(2040256374931197952) + serviceID),
+ "request": map[string]interface{}{
+ "query": "公告",
+ "user_id": AnyToJSON(2040256374931197952),
+ "query_info": map[string]interface{}{
+ "asr_candidates": []string{},
+ "source": "KEYBOARD",
+ "type": "TEXT",
+ },
+ },
+ "bernard_level": 1,
+ }
+ t.Log(params2)
+ client3 := NewClient(baiDuRequestURLForRobotDialogue+"?access_token="+response.AccessToken,
+ MethodForPost, params2)
+
+ resp3, err := client3.Request(RequestBodyFormatForRaw, Headers{ContentType: "application/json; charset=UTF-8"})
+
+ if err != nil {
+ t.Log(err)
+ return
+ }
+ response3 := new(BaiDuRobotDialogue)
+
+ _ = FromJSONBytes(resp3, response3)
+
+ t.Log(AnyToJSON(response3))
+
+ return
+ //
+ //client1 := NewClient("http://vop.baidu.com/server_api", MethodForPost, params)
+ //
+ //resp1 := make([]byte, 0)
+ //
+ //if resp1, err = client1.Request(RequestBodyFormatForRaw, Headers{
+ // ContentType: "application/json",
+ //}); err != nil {
+ // t.Log(err)
+ // return
+ //}
+ //response1 := new(BaiDuSpeechQuick)
+ //
+ //_ = FromJSONBytes(resp1, response1)
+ //
+ //t.Logf("resp:%v\n", AnyToJSON(response1))
+}
+
+func TestClient_Request(t *testing.T) {
+ request := NewClient("https://image1.ljcdn.com/hdic-resblock/4494aa6e-4165-4f4a-b7ba-4ab095dd1ffa.JPG.710x400.jpg", "GET", nil)
+
+ resp, err := request.Request(RequestBodyFormatForFormData, Headers{
+ Others: map[string]string{
+ "Referer": "http://drc.hefei.gov.cn/group4/M00/07/4D/wKgEIWEM9X-AXLhsAAONk965l5o088.png",
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36",
+ "Cookie": "__jsluid_h=9fcece02433a024c638dd5e8d4cf6f92; __jsl_clearance=1628842172.968|0|8rBRZzH5SoW3MMG1%2FWkYpLUeRXA%3D",
+ },
+ })
+ f, err := os.Create("test.jpg")
+ if err != nil {
+ log.Fatal("Couldn't open file")
+ }
+ defer f.Close()
+
+ err = binary.Write(f, binary.LittleEndian, resp)
+
+ if err != nil {
+ log.Fatal("Write failed")
+ }
+
+ //resp, err := request.Request(RequestBodyFormatForFormData, Headers{
+ // //Others: map[string]string{
+ // // "Referer": "http://drc.hefei.gov.cn/group4/M00/07/4D/wKgEIWEM9X-AXLhsAAONk965l5o088.png",
+ // // "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36",
+ // // "Cookie": "__jsluid_h=2844bb494bad8b1cd372e28c65844abd; __jsl_clearance=1628840623.068|0|vNUfDD1V4muQrHrWy%2BmhoGbOFr0%3D",
+ // //},
+ //})
+ //f, err := os.Create("test.jpg")
+ //if err != nil {
+ // log.Fatal("Couldn't open file")
+ //}
+ //defer f.Close()
+ //
+ //err = binary.Write(f, binary.LittleEndian, resp)
+ //
+ //if err != nil {
+ // log.Fatal("Write failed")
+ //}
+}
diff --git a/utils/snowflake.go b/utils/snowflake.go
new file mode 100644
index 0000000..834a045
--- /dev/null
+++ b/utils/snowflake.go
@@ -0,0 +1,55 @@
+package utils
+
+import (
+ "errors"
+ "sync"
+ "time"
+)
+
+const (
+ workerBits uint8 = 10
+ numberBits uint8 = 12
+ workerMax int64 = -1 ^ (-1 << workerBits)
+ numberMax int64 = -1 ^ (-1 << numberBits)
+ timeShift uint8 = workerBits + numberBits
+ workerShift uint8 = numberBits
+ startTime int64 = 1136185445000
+)
+
+type Worker struct {
+ mu sync.Mutex
+ timestamp int64
+ workerID int64
+ number int64
+}
+
+func (w *Worker) GetID() int64 {
+ w.mu.Lock()
+ defer w.mu.Unlock()
+ now := time.Now().UnixNano() / 1e6
+
+ if w.timestamp == now {
+ w.number++
+ if w.number > numberMax {
+ for now <= w.timestamp {
+ now = time.Now().UnixNano() / 1e6
+ }
+ }
+ } else {
+ w.number = 0
+ w.timestamp = now
+ }
+ return (now-startTime)< workerMax {
+ return nil, errors.New("Worker ID Excess Of Quantity")
+ }
+ // 生成一个新节点
+ return &Worker{
+ timestamp: 0,
+ workerID: workerID,
+ number: 0,
+ }, nil
+}
diff --git a/utils/strconv.go b/utils/strconv.go
new file mode 100644
index 0000000..a1e5485
--- /dev/null
+++ b/utils/strconv.go
@@ -0,0 +1,38 @@
+package utils
+
+import (
+ "fmt"
+ "strconv"
+)
+
+func StringToInt(src string) int {
+ dst, _ := strconv.Atoi(src)
+ return dst
+}
+
+func StringToInt64(src string) int64 {
+ dst, _ := strconv.ParseInt(src, 10, 64)
+ return dst
+}
+
+func StringToUnit(src string) uint {
+ dst, _ := strconv.Atoi(src)
+ return uint(dst)
+}
+
+func StringToUnit64(src string) uint64 {
+ dst, _ := strconv.ParseUint(src, 10, 64)
+ return dst
+}
+
+func StringToFloat(src string) (float64, error) {
+ return strconv.ParseFloat(src, 64)
+}
+
+func IntToString(src int64) string {
+ return fmt.Sprintf("%d", src)
+}
+
+func UintToString(src uint64) string {
+ return fmt.Sprintf("%d", src)
+}
diff --git a/utils/string.go b/utils/string.go
new file mode 100644
index 0000000..52ad0ae
--- /dev/null
+++ b/utils/string.go
@@ -0,0 +1,30 @@
+package utils
+
+import (
+ "strings"
+)
+
+func ToLowerCase(src []rune) rune {
+ return src[0] | 0x20
+}
+
+func ToUpperCase(src []rune) rune {
+ return src[0] ^ 0x20
+}
+
+func ToSnake(src, delimiter string) string {
+ src = strings.TrimSpace(src)
+ objs := strings.Split(src, delimiter)
+
+ out := make([]rune, 0)
+
+ for _, v := range objs {
+ if len(v) <= 0 {
+ continue
+ }
+ obj := []rune(v)
+ obj[0] = ToUpperCase(obj)
+ out = append(out, obj...)
+ }
+ return string(out)
+}
diff --git a/utils/string_test.go b/utils/string_test.go
new file mode 100644
index 0000000..919e809
--- /dev/null
+++ b/utils/string_test.go
@@ -0,0 +1,8 @@
+package utils
+
+import "testing"
+
+func TestToSnake(t *testing.T) {
+ src := "sys_"
+ t.Log(ToSnake(src, "_"))
+}
diff --git a/utils/time.go b/utils/time.go
new file mode 100644
index 0000000..b8ff974
--- /dev/null
+++ b/utils/time.go
@@ -0,0 +1,68 @@
+package utils
+
+import (
+ "math"
+ "time"
+)
+
+type Week int
+
+const (
+ Monday Week = iota + 1
+ Tuesday
+ Wednesday
+ Thursday
+ Friday
+ Saturday
+ Sunday
+)
+
+func IsEmptyTime(t time.Time) bool {
+ return t.IsZero()
+}
+
+func FormatDate(t time.Time) string {
+ return t.Format("2006-01-02")
+}
+
+func FormatDatetime(t time.Time) string {
+ return t.Format("2006-01-02 15:04:05")
+}
+
+func FormatTimeForLayout(t time.Time, layout string) string {
+ return t.Format(layout)
+}
+
+func DateTimeToTime(t string) time.Time {
+ _time, _ := time.ParseInLocation("2006-01-02 15:04:05", t, time.Local)
+ return _time
+}
+
+func DataTimeToDate(t string) time.Time {
+ _time, _ := time.ParseInLocation("2006-01-02", t, time.Local)
+ return _time
+}
+
+func GetMondayTime(t time.Time) time.Time {
+ offset := int(time.Monday - t.Weekday())
+
+ if offset > 0 {
+ offset = -6
+ }
+ return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
+}
+
+func MonthBeginAt(year, month int) time.Time {
+ return time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.Now().Location())
+}
+
+func MonthFinishAt(year, month int) time.Time {
+ mark := time.Date(year, time.Month(month), 1, 23, 59, 59, 0, time.Now().Location())
+ return mark.AddDate(0, 1, -1)
+}
+
+func DiffTimeMonth(time1, time2 time.Time) int {
+ year := math.Abs(float64(time1.Year()) - float64(time2.Year()))
+ month := math.Abs(float64(time1.Month()) - float64(time2.Month()))
+ return int(year)*12 + int(month) + 1
+}