commit
de5d4e91ef
@ -9,4 +9,4 @@ name = "go"
|
||||
enabled = true
|
||||
|
||||
[analyzers.meta]
|
||||
import_paths = ["github.com/beego/beego"]
|
||||
import_paths = ["github.com/beego/beego/v2"]
|
||||
|
||||
4
.github/linters/.golangci.yml
vendored
4
.github/linters/.golangci.yml
vendored
@ -38,6 +38,6 @@ linters:
|
||||
|
||||
linters-settings:
|
||||
gci:
|
||||
local-prefixes: github.com/beego/beego
|
||||
local-prefixes: github.com/beego
|
||||
goimports:
|
||||
local-prefixes: github.com/beego/beego
|
||||
local-prefixes: github.com/beego
|
||||
|
||||
@ -89,5 +89,3 @@ Also when filing an issue, make sure to answer these five questions:
|
||||
Please take a moment to check that an issue doesn't already exist documenting your bug report or improvement proposal.
|
||||
If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common
|
||||
problems and requests.
|
||||
|
||||
Also, if you don't know how to use it. please make sure you have read through the docs in http://beego.vip/docs
|
||||
|
||||
4
Makefile
4
Makefile
@ -62,3 +62,7 @@ test-orm-tidb: ## Run ORM unit tests on tidb.
|
||||
|
||||
.PHONY: test-orm-all
|
||||
test-orm-all: test-orm-mysql5 test-orm-mysql8 test-orm-pgsql test-orm-tidb
|
||||
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
goimports -local "github.com/beego/beego" -w .
|
||||
@ -86,7 +86,6 @@ Congratulations! You've just built your first **beego** app.
|
||||
|
||||
## Community
|
||||
|
||||
* [http://beego.vip/community](http://beego.vip/community)
|
||||
* Welcome to join us in Slack: [https://beego.slack.com invite](https://join.slack.com/t/beego/shared_invite/zt-fqlfjaxs-_CRmiITCSbEqQG9NeBqXKA),
|
||||
* QQ Group ID:523992905
|
||||
* [Contribution Guide](https://github.com/beego/beedoc/blob/master/en-US/intro/contributing.md).
|
||||
|
||||
1
adapter/cache/cache.go
vendored
1
adapter/cache/cache.go
vendored
@ -28,7 +28,6 @@
|
||||
// bm.IsExist("astaxie")
|
||||
// bm.Delete("astaxie")
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/cache.md
|
||||
package cache
|
||||
|
||||
import (
|
||||
|
||||
1
adapter/cache/memcache/memcache.go
vendored
1
adapter/cache/memcache/memcache.go
vendored
@ -26,7 +26,6 @@
|
||||
//
|
||||
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/cache.md
|
||||
package memcache
|
||||
|
||||
import (
|
||||
|
||||
1
adapter/cache/redis/redis.go
vendored
1
adapter/cache/redis/redis.go
vendored
@ -26,7 +26,6 @@
|
||||
//
|
||||
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/cache.md
|
||||
package redis
|
||||
|
||||
import (
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
// cnf.DIY(key string) (interface{}, error)
|
||||
// cnf.GetSection(section string) (map[string]string, error)
|
||||
// cnf.SaveConfigFile(filename string) error
|
||||
// More docs http://beego.vip/docs/module/config.md
|
||||
package config
|
||||
|
||||
import (
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
//
|
||||
// cnf, err := config.NewConfig("xml", "config.xml")
|
||||
//
|
||||
// More docs http://beego.vip/docs/module/config.md
|
||||
package xml
|
||||
|
||||
import (
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
//
|
||||
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
||||
//
|
||||
// More docs http://beego.vip/docs/module/config.md
|
||||
package yaml
|
||||
|
||||
import (
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
//
|
||||
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/context.md
|
||||
package context
|
||||
|
||||
import (
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
// }
|
||||
// fmt.Println(str)
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/httplib.md
|
||||
package httplib
|
||||
|
||||
import (
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
// log.Debug("debug")
|
||||
// log.Critical("critical")
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/logs.md
|
||||
package logs
|
||||
|
||||
import (
|
||||
|
||||
@ -15,8 +15,6 @@
|
||||
package logs
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
@ -40,30 +38,6 @@ func (o *oldToNewAdapter) Flush() {
|
||||
o.old.Flush()
|
||||
}
|
||||
|
||||
func (o *oldToNewAdapter) SetFormatter(f logs.LogFormatter) {
|
||||
func (*oldToNewAdapter) SetFormatter(f logs.LogFormatter) {
|
||||
panic("unsupported operation, you should not invoke this method")
|
||||
}
|
||||
|
||||
type newToOldAdapter struct {
|
||||
n logs.Logger
|
||||
}
|
||||
|
||||
func (n *newToOldAdapter) Init(config string) error {
|
||||
return n.n.Init(config)
|
||||
}
|
||||
|
||||
func (n *newToOldAdapter) WriteMsg(when time.Time, msg string, level int) error {
|
||||
return n.n.WriteMsg(&logs.LogMsg{
|
||||
When: when,
|
||||
Msg: msg,
|
||||
Level: level,
|
||||
})
|
||||
}
|
||||
|
||||
func (n *newToOldAdapter) Destroy() {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (n *newToOldAdapter) Flush() {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
@ -51,7 +51,6 @@
|
||||
// num, err = o.Delete(&u)
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/mvc/model/overview.md
|
||||
package orm
|
||||
|
||||
import (
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package couchbase
|
||||
|
||||
import (
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package memcache
|
||||
|
||||
import (
|
||||
|
||||
@ -37,14 +37,12 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
// import mysql driver
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
|
||||
"github.com/beego/beego/v2/adapter/session"
|
||||
|
||||
@ -47,14 +47,12 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
// import postgresql Driver
|
||||
_ "github.com/lib/pq"
|
||||
|
||||
"github.com/beego/beego/v2/adapter/session"
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package redis
|
||||
|
||||
import (
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package redis_cluster
|
||||
|
||||
import (
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package session
|
||||
|
||||
import (
|
||||
|
||||
@ -106,7 +106,6 @@ func Htmlunquote(text string) string {
|
||||
// /login?next=/
|
||||
// /user/John%20Doe
|
||||
//
|
||||
// more detail http://beego.vip/docs/mvc/controller/urlbuilding.md
|
||||
func URLFor(endpoint string, values ...interface{}) string {
|
||||
return web.URLFor(endpoint, values...)
|
||||
}
|
||||
|
||||
@ -27,7 +27,6 @@
|
||||
//
|
||||
// AddHealthCheck("database",&DatabaseCheck{})
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/toolbox.md
|
||||
package toolbox
|
||||
|
||||
import (
|
||||
|
||||
@ -237,6 +237,7 @@ func (ms *MapSorter) Sort() {
|
||||
}
|
||||
|
||||
func (ms *MapSorter) Len() int { return len(ms.Keys) }
|
||||
|
||||
func (ms *MapSorter) Less(i, j int) bool {
|
||||
if ms.Vals[i].GetNext(context.Background()).IsZero() {
|
||||
return false
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
// Copyright 2014 beego Author. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package toolbox
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
defer ClearTask()
|
||||
|
||||
tk := NewTask("taska", "0/30 * * * * *", func() error { fmt.Println("hello world"); return nil })
|
||||
err := tk.Run()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
AddTask("taska", tk)
|
||||
StartTask()
|
||||
time.Sleep(6 * time.Second)
|
||||
StopTask()
|
||||
}
|
||||
|
||||
//func TestSpec(t *testing.T) {
|
||||
// defer ClearTask()
|
||||
//
|
||||
// wg := &sync.WaitGroup{}
|
||||
// wg.Add(2)
|
||||
// tk1 := NewTask("tk1", "0 12 * * * *", func() error { fmt.Println("tk1"); return nil })
|
||||
// tk2 := NewTask("tk2", "0,10,20 * * * * *", func() error { fmt.Println("tk2"); wg.Done(); return nil })
|
||||
// tk3 := NewTask("tk3", "0 10 * * * *", func() error { fmt.Println("tk3"); wg.Done(); return nil })
|
||||
//
|
||||
// AddTask("tk1", tk1)
|
||||
// AddTask("tk2", tk2)
|
||||
// AddTask("tk3", tk3)
|
||||
// StartTask()
|
||||
// defer StopTask()
|
||||
//
|
||||
// select {
|
||||
// case <-time.After(200 * time.Second):
|
||||
// t.FailNow()
|
||||
// case <-wait(wg):
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func wait(wg *sync.WaitGroup) chan bool {
|
||||
// ch := make(chan bool)
|
||||
// go func() {
|
||||
// wg.Wait()
|
||||
// ch <- true
|
||||
// }()
|
||||
// return ch
|
||||
//}
|
||||
@ -50,9 +50,5 @@ In your view templates:
|
||||
</ul>
|
||||
{{end}}
|
||||
|
||||
See also
|
||||
|
||||
http://beego.vip/docs/mvc/view/page.md
|
||||
|
||||
*/
|
||||
package pagination
|
||||
|
||||
@ -43,7 +43,6 @@
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// more info: http://beego.vip/docs/mvc/controller/validation.md
|
||||
package validation
|
||||
|
||||
import (
|
||||
|
||||
1
client/cache/cache.go
vendored
1
client/cache/cache.go
vendored
@ -28,7 +28,6 @@
|
||||
// bm.IsExist("astaxie")
|
||||
// bm.Delete("astaxie")
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/cache.md
|
||||
package cache
|
||||
|
||||
import (
|
||||
|
||||
1
client/cache/memcache/memcache.go
vendored
1
client/cache/memcache/memcache.go
vendored
@ -26,7 +26,6 @@
|
||||
//
|
||||
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/cache.md
|
||||
package memcache
|
||||
|
||||
import (
|
||||
|
||||
3
client/cache/memcache/memcache_test.go
vendored
3
client/cache/memcache/memcache_test.go
vendored
@ -24,12 +24,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
|
||||
_ "github.com/bradfitz/gomemcache/memcache"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/beego/beego/v2/client/cache"
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
)
|
||||
|
||||
func TestMemcacheCache(t *testing.T) {
|
||||
|
||||
3
client/cache/read_through_test.go
vendored
3
client/cache/read_through_test.go
vendored
@ -20,8 +20,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
)
|
||||
|
||||
func TestReadThroughCache_Memory_Get(t *testing.T) {
|
||||
|
||||
1
client/cache/redis/redis.go
vendored
1
client/cache/redis/redis.go
vendored
@ -26,7 +26,6 @@
|
||||
//
|
||||
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/cache.md
|
||||
package redis
|
||||
|
||||
import (
|
||||
|
||||
3
client/cache/redis/redis_test.go
vendored
3
client/cache/redis/redis_test.go
vendored
@ -22,12 +22,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/beego/beego/v2/client/cache"
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
)
|
||||
|
||||
func TestRedisCache(t *testing.T) {
|
||||
|
||||
3
client/cache/singleflight.go
vendored
3
client/cache/singleflight.go
vendored
@ -18,8 +18,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
"golang.org/x/sync/singleflight"
|
||||
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
)
|
||||
|
||||
// SingleflightCache
|
||||
|
||||
3
client/cache/ssdb/ssdb_test.go
vendored
3
client/cache/ssdb/ssdb_test.go
vendored
@ -10,11 +10,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/beego/beego/v2/client/cache"
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
)
|
||||
|
||||
func TestSsdbcacheCache(t *testing.T) {
|
||||
|
||||
3
client/cache/write_through_test.go
vendored
3
client/cache/write_through_test.go
vendored
@ -22,8 +22,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/beego/beego/v2/core/berror"
|
||||
)
|
||||
|
||||
func TestWriteThoughCache_Set(t *testing.T) {
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
// }
|
||||
// fmt.Println(str)
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/httplib.md
|
||||
package httplib
|
||||
|
||||
import (
|
||||
|
||||
@ -28,14 +28,13 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestResponse(t *testing.T) {
|
||||
req := Get("http://httpbin.org/get")
|
||||
resp, err := req.Response()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(resp)
|
||||
}
|
||||
|
||||
@ -53,9 +52,7 @@ func TestDoRequest(t *testing.T) {
|
||||
startTime := time.Now().UnixNano() / int64(time.Millisecond)
|
||||
|
||||
_, err := req.Response()
|
||||
if err == nil {
|
||||
t.Fatal("Response should have yielded an error")
|
||||
}
|
||||
require.Error(t, err)
|
||||
|
||||
endTime := time.Now().UnixNano() / int64(time.Millisecond)
|
||||
elapsedTime := endTime - startTime
|
||||
@ -69,20 +66,13 @@ func TestDoRequest(t *testing.T) {
|
||||
func TestGet(t *testing.T) {
|
||||
req := Get("http://httpbin.org/get")
|
||||
b, err := req.Bytes()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(b)
|
||||
|
||||
s, err := req.String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(s)
|
||||
|
||||
if string(b) != s {
|
||||
t.Fatal("request data not match")
|
||||
}
|
||||
require.Equal(t, string(b), s)
|
||||
}
|
||||
|
||||
func TestSimplePost(t *testing.T) {
|
||||
@ -91,15 +81,11 @@ func TestSimplePost(t *testing.T) {
|
||||
req.Param("username", v)
|
||||
|
||||
str, err := req.String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
|
||||
n := strings.Index(str, v)
|
||||
if n == -1 {
|
||||
t.Fatal(v + " not found in post")
|
||||
}
|
||||
require.NotEqual(t, -1, n)
|
||||
}
|
||||
|
||||
// func TestPostFile(t *testing.T) {
|
||||
@ -123,40 +109,30 @@ func TestSimplePost(t *testing.T) {
|
||||
|
||||
func TestSimplePut(t *testing.T) {
|
||||
str, err := Put("http://httpbin.org/put").String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
}
|
||||
|
||||
func TestSimpleDelete(t *testing.T) {
|
||||
str, err := Delete("http://httpbin.org/delete").String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
}
|
||||
|
||||
func TestSimpleDeleteParam(t *testing.T) {
|
||||
str, err := Delete("http://httpbin.org/delete").Param("key", "val").String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
}
|
||||
|
||||
func TestWithCookie(t *testing.T) {
|
||||
v := "smallfish"
|
||||
str, err := Get("http://httpbin.org/cookies/set?k1=" + v).SetEnableCookie(true).String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
|
||||
str, err = Get("http://httpbin.org/cookies").SetEnableCookie(true).String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
|
||||
n := strings.Index(str, v)
|
||||
@ -167,9 +143,7 @@ func TestWithCookie(t *testing.T) {
|
||||
|
||||
func TestWithBasicAuth(t *testing.T) {
|
||||
str, err := Get("http://httpbin.org/basic-auth/user/passwd").SetBasicAuth("user", "passwd").String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
n := strings.Index(str, "authenticated")
|
||||
if n == -1 {
|
||||
@ -180,9 +154,7 @@ func TestWithBasicAuth(t *testing.T) {
|
||||
func TestWithUserAgent(t *testing.T) {
|
||||
v := "beego"
|
||||
str, err := Get("http://httpbin.org/headers").SetUserAgent(v).String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
|
||||
n := strings.Index(str, v)
|
||||
@ -210,9 +182,7 @@ func TestWithSetting(t *testing.T) {
|
||||
SetDefaultSetting(setting)
|
||||
|
||||
str, err := Get("http://httpbin.org/get").String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
|
||||
n := strings.Index(str, v)
|
||||
@ -224,9 +194,7 @@ func TestWithSetting(t *testing.T) {
|
||||
func TestToJson(t *testing.T) {
|
||||
req := Get("http://httpbin.org/ip")
|
||||
resp, err := req.Response()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(resp)
|
||||
|
||||
// httpbin will return http remote addr
|
||||
@ -235,9 +203,7 @@ func TestToJson(t *testing.T) {
|
||||
}
|
||||
var ip IP
|
||||
err = req.ToJSON(&ip)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(ip.Origin)
|
||||
ips := strings.Split(ip.Origin, ",")
|
||||
if len(ips) == 0 {
|
||||
@ -254,9 +220,7 @@ func TestToFile(t *testing.T) {
|
||||
f := "beego_testfile"
|
||||
req := Get("http://httpbin.org/ip")
|
||||
err := req.ToFile(f)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
defer os.Remove(f)
|
||||
b, err := ioutil.ReadFile(f)
|
||||
if n := bytes.Index(b, []byte("origin")); n == -1 {
|
||||
@ -268,9 +232,7 @@ func TestToFileDir(t *testing.T) {
|
||||
f := "./files/beego_testfile"
|
||||
req := Get("http://httpbin.org/ip")
|
||||
err := req.ToFile(f)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll("./files")
|
||||
b, err := ioutil.ReadFile(f)
|
||||
if n := bytes.Index(b, []byte("origin")); n == -1 {
|
||||
@ -282,9 +244,7 @@ func TestHeader(t *testing.T) {
|
||||
req := Get("http://httpbin.org/headers")
|
||||
req.Header("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36")
|
||||
str, err := req.String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
t.Log(str)
|
||||
}
|
||||
|
||||
|
||||
@ -151,9 +151,3 @@ like this:
|
||||
|
||||
note: not recommend use this in product env.
|
||||
|
||||
## Docs
|
||||
|
||||
more details and examples in docs and test
|
||||
|
||||
[documents](http://beego.vip/docs/mvc/model/overview.md)
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ func (builder *FilterChainBuilder) buildSpan(ctx context.Context, span otelTrace
|
||||
span.SetAttributes(attribute.String("component", "beego"))
|
||||
|
||||
if builder.customSpanFunc != nil {
|
||||
builder.customSpanFunc(ctx,span, inv)
|
||||
builder.customSpanFunc(ctx, span, inv)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@
|
||||
// num, err = o.Delete(&u)
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/mvc/model/overview.md
|
||||
package orm
|
||||
|
||||
import (
|
||||
|
||||
@ -27,7 +27,6 @@
|
||||
//
|
||||
// AddHealthCheck("database",&DatabaseCheck{})
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/toolbox.md
|
||||
package admin
|
||||
|
||||
// AdminCheckList holds health checker map
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
// cnf.DIY(key string) (interface{}, error)
|
||||
// cnf.GetSection(section string) (map[string]string, error)
|
||||
// cnf.SaveConfigFile(filename string) error
|
||||
// More docs http://beego.vip/docs/module/config.md
|
||||
package config
|
||||
|
||||
import (
|
||||
|
||||
@ -19,8 +19,9 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/core/config"
|
||||
"github.com/pelletier/go-toml"
|
||||
|
||||
"github.com/beego/beego/v2/core/config"
|
||||
)
|
||||
|
||||
const keySeparator = "."
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
//
|
||||
// cnf, err := config.NewConfig("xml", "config.xml")
|
||||
//
|
||||
// More docs http://beego.vip/docs/module/config.md
|
||||
package xml
|
||||
|
||||
import (
|
||||
@ -39,11 +38,11 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/beego/x2j"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
||||
"github.com/beego/beego/v2/core/config"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/x2j"
|
||||
)
|
||||
|
||||
// Config is a xml config parser and implements Config interface.
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
//
|
||||
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
||||
//
|
||||
// More docs http://beego.vip/docs/module/config.md
|
||||
package yaml
|
||||
|
||||
import (
|
||||
|
||||
@ -11,7 +11,9 @@ import (
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
|
||||
var _ = fmt.Errorf
|
||||
|
||||
var _ = math.Inf
|
||||
|
||||
var (
|
||||
@ -339,6 +341,7 @@ func encodeFixed64Log(data []byte, offset int, v uint64) int {
|
||||
data[offset+7] = uint8(v >> 56)
|
||||
return offset + 8
|
||||
}
|
||||
|
||||
func encodeFixed32Log(data []byte, offset int, v uint32) int {
|
||||
data[offset] = uint8(v)
|
||||
data[offset+1] = uint8(v >> 8)
|
||||
@ -346,6 +349,7 @@ func encodeFixed32Log(data []byte, offset int, v uint32) int {
|
||||
data[offset+3] = uint8(v >> 24)
|
||||
return offset + 4
|
||||
}
|
||||
|
||||
func encodeVarintLog(data []byte, offset int, v uint64) int {
|
||||
for v >= 1<<7 {
|
||||
data[offset] = uint8(v&0x7f | 0x80)
|
||||
@ -447,6 +451,7 @@ func sovLog(x uint64) (n int) {
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sozLog(x uint64) (n int) {
|
||||
return sovLog((x << 1) ^ (x >> 63))
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
// log.Debug("debug")
|
||||
// log.Critical("critical")
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/logs.md
|
||||
package logs
|
||||
|
||||
import (
|
||||
|
||||
@ -50,9 +50,5 @@ In your view templates:
|
||||
</ul>
|
||||
{{end}}
|
||||
|
||||
See also
|
||||
|
||||
http://beego.vip/docs/mvc/view/page.md
|
||||
|
||||
*/
|
||||
package pagination
|
||||
|
||||
@ -43,7 +43,6 @@
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// more info: http://beego.vip/docs/mvc/controller/validation.md
|
||||
package validation
|
||||
|
||||
import (
|
||||
|
||||
6
go.mod
6
go.mod
@ -31,8 +31,8 @@ require (
|
||||
github.com/stretchr/testify v1.8.1
|
||||
go.etcd.io/etcd/client/v3 v3.5.4
|
||||
go.opentelemetry.io/otel v1.11.2
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.8.0
|
||||
go.opentelemetry.io/otel/sdk v1.8.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2
|
||||
go.opentelemetry.io/otel/sdk v1.11.2
|
||||
go.opentelemetry.io/otel/trace v1.11.2
|
||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
|
||||
@ -73,7 +73,7 @@ require (
|
||||
go.uber.org/multierr v1.7.0 // indirect
|
||||
go.uber.org/zap v1.19.1 // indirect
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
|
||||
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
|
||||
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect
|
||||
)
|
||||
|
||||
12
go.sum
12
go.sum
@ -336,10 +336,10 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opentelemetry.io/otel v1.11.2 h1:YBZcQlsVekzFsFbjygXMOXSs6pialIZxcjfO/mBDmR0=
|
||||
go.opentelemetry.io/otel v1.11.2/go.mod h1:7p4EUV+AqgdlNV9gL97IgUZiVR3yrFXYo53f9BM3tRI=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.8.0 h1:FVy7BZCjoA2Nk+fHqIdoTmm554J9wTX+YcrDp+mc368=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.8.0/go.mod h1:ztncjvKpotSUQq7rlgPibGt8kZfSI3/jI8EO7JjuY2c=
|
||||
go.opentelemetry.io/otel/sdk v1.8.0 h1:xwu69/fNuwbSHWe/0PGS888RmjWY181OmcXDQKu7ZQk=
|
||||
go.opentelemetry.io/otel/sdk v1.8.0/go.mod h1:uPSfc+yfDH2StDM/Rm35WE8gXSNdvCg023J6HeGNO0c=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2 h1:BhEVgvuE1NWLLuMLvC6sif791F45KFHi5GhOs1KunZU=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2/go.mod h1:bx//lU66dPzNT+Y0hHA12ciKoMOH9iixEwCqC1OeQWQ=
|
||||
go.opentelemetry.io/otel/sdk v1.11.2 h1:GF4JoaEx7iihdMFu30sOyRx52HDHOkl9xQ8SMqNXUiU=
|
||||
go.opentelemetry.io/otel/sdk v1.11.2/go.mod h1:wZ1WxImwpq+lVRo4vsmSOxdd+xwoUJ6rqyLc3SyX9aU=
|
||||
go.opentelemetry.io/otel/trace v1.11.2 h1:Xf7hWSF2Glv0DE3MH7fBHvtpSBsjcBUe5MYAmZM/+y0=
|
||||
go.opentelemetry.io/otel/trace v1.11.2/go.mod h1:4N+yC7QEz7TTsG9BSRLNAa63eg5E06ObSbKPmxQ/pKA=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
@ -495,8 +495,8 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 h1:TyKJRhyo17yWxOMCTHKWrc5rddHORMlnZ/j57umaUd8=
|
||||
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 h1:h+EGohizhe9XlX18rfpa8k8RAc5XyaeamM+0VHRd4lc=
|
||||
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
//
|
||||
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
||||
//
|
||||
// more docs http://beego.vip/docs/module/context.md
|
||||
package context
|
||||
|
||||
import (
|
||||
|
||||
@ -96,9 +96,11 @@ type ControllerComments struct {
|
||||
// ControllerCommentsSlice implements the sort interface
|
||||
type ControllerCommentsSlice []ControllerComments
|
||||
|
||||
func (p ControllerCommentsSlice) Len() int { return len(p) }
|
||||
func (p ControllerCommentsSlice) Len() int { return len(p) }
|
||||
|
||||
func (p ControllerCommentsSlice) Less(i, j int) bool { return p[i].Router < p[j].Router }
|
||||
func (p ControllerCommentsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
||||
func (p ControllerCommentsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
||||
// Controller defines some basic http request handler operations, such as
|
||||
// http context, template and view, session and xsrf.
|
||||
|
||||
@ -12,6 +12,5 @@ beego is inspired by Tornado, Sinatra and Flask with the added benefit of some G
|
||||
beego.Run()
|
||||
}
|
||||
|
||||
more information: http://beego.vip
|
||||
*/
|
||||
package web
|
||||
|
||||
@ -53,8 +53,8 @@ var defaultRejectionResponse = RejectionResponse{
|
||||
// according to the configuration.
|
||||
func NewLimiter(opts ...limiterOption) web.FilterFunc {
|
||||
l := &limiter{
|
||||
buckets: make(map[string]bucket),
|
||||
sessionKey: defaultSessionKey,
|
||||
buckets: make(map[string]bucket),
|
||||
sessionKey: defaultSessionKey,
|
||||
rate: time.Millisecond * 10,
|
||||
capacity: 100,
|
||||
bucketFactory: newTokenBucket,
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package couchbase
|
||||
|
||||
import (
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package memcache
|
||||
|
||||
import (
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package mysql
|
||||
|
||||
import (
|
||||
@ -47,7 +46,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
// import mysql driver
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
|
||||
@ -47,7 +47,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package postgres
|
||||
|
||||
import (
|
||||
@ -57,7 +56,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
// import postgresql Driver
|
||||
_ "github.com/lib/pq"
|
||||
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package redis
|
||||
|
||||
import (
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package redis_cluster
|
||||
|
||||
import (
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
// go globalSessions.GC()
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.vip/docs/module/session.md
|
||||
package session
|
||||
|
||||
import (
|
||||
|
||||
@ -242,7 +242,6 @@ func Htmlunquote(text string) string {
|
||||
// /login?next=/
|
||||
// /user/John%20Doe
|
||||
//
|
||||
// more detail http://beego.vip/docs/mvc/controller/urlbuilding.md
|
||||
func URLFor(endpoint string, values ...interface{}) string {
|
||||
return BeeApp.Handlers.URLFor(endpoint, values...)
|
||||
}
|
||||
|
||||
@ -697,6 +697,7 @@ func (ms *MapSorter) Sort() {
|
||||
}
|
||||
|
||||
func (ms *MapSorter) Len() int { return len(ms.Keys) }
|
||||
|
||||
func (ms *MapSorter) Less(i, j int) bool {
|
||||
if ms.Vals[i].GetNext(context.Background()).IsZero() {
|
||||
return false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user