format code

This commit is contained in:
Deng Ming 2022-12-23 10:25:06 +08:00
parent 15fa7e15d4
commit 5ade9fa025
64 changed files with 35 additions and 109 deletions

View File

@ -9,4 +9,4 @@ name = "go"
enabled = true
[analyzers.meta]
import_paths = ["github.com/beego/beego"]
import_paths = ["github.com/beego/beego/v2"]

View File

@ -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

View File

@ -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

View File

@ -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 .

View File

@ -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).

View File

@ -28,7 +28,6 @@
// bm.IsExist("astaxie")
// bm.Delete("astaxie")
//
// more docs http://beego.vip/docs/module/cache.md
package cache
import (

View File

@ -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 (

View File

@ -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 (

View File

@ -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 (

View File

@ -26,7 +26,6 @@
//
// cnf, err := config.NewConfig("xml", "config.xml")
//
// More docs http://beego.vip/docs/module/config.md
package xml
import (

View File

@ -26,7 +26,6 @@
//
// cnf, err := config.NewConfig("yaml", "config.yaml")
//
// More docs http://beego.vip/docs/module/config.md
package yaml
import (

View File

@ -19,7 +19,6 @@
//
// ctx := context.Context{Request:req,ResponseWriter:rw}
//
// more docs http://beego.vip/docs/module/context.md
package context
import (

View File

@ -28,7 +28,6 @@
// }
// fmt.Println(str)
//
// more docs http://beego.vip/docs/module/httplib.md
package httplib
import (

View File

@ -30,7 +30,6 @@
// log.Debug("debug")
// log.Critical("critical")
//
// more docs http://beego.vip/docs/module/logs.md
package logs
import (

View File

@ -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")
}

View File

@ -51,7 +51,6 @@
// num, err = o.Delete(&u)
// }
//
// more docs: http://beego.vip/docs/mvc/model/overview.md
package orm
import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package couchbase
import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package memcache
import (

View File

@ -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"

View File

@ -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"

View File

@ -29,7 +29,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package redis
import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package redis_cluster
import (

View File

@ -24,7 +24,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package session
import (

View File

@ -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...)
}

View File

@ -27,7 +27,6 @@
//
// AddHealthCheck("database",&DatabaseCheck{})
//
// more docs: http://beego.vip/docs/module/toolbox.md
package toolbox
import (

View File

@ -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

View File

@ -50,9 +50,5 @@ In your view templates:
</ul>
{{end}}
See also
http://beego.vip/docs/mvc/view/page.md
*/
package pagination

View File

@ -43,7 +43,6 @@
// }
// }
//
// more info: http://beego.vip/docs/mvc/controller/validation.md
package validation
import (

View File

@ -28,7 +28,6 @@
// bm.IsExist("astaxie")
// bm.Delete("astaxie")
//
// more docs http://beego.vip/docs/module/cache.md
package cache
import (

View File

@ -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 (

View File

@ -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) {

View File

@ -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) {

View File

@ -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 (

View File

@ -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) {

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -28,7 +28,6 @@
// }
// fmt.Println(str)
//
// more docs http://beego.vip/docs/module/httplib.md
package httplib
import (

View File

@ -19,7 +19,6 @@ import (
"context"
"errors"
"fmt"
"github.com/stretchr/testify/require"
"io/ioutil"
"net"
"net/http"
@ -29,6 +28,7 @@ import (
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestResponse(t *testing.T) {

View File

@ -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)

View File

@ -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)
}
}

View File

@ -51,7 +51,6 @@
// num, err = o.Delete(&u)
// }
//
// more docs: http://beego.vip/docs/mvc/model/overview.md
package orm
import (

View File

@ -27,7 +27,6 @@
//
// AddHealthCheck("database",&DatabaseCheck{})
//
// more docs: http://beego.vip/docs/module/toolbox.md
package admin
// AdminCheckList holds health checker map

View File

@ -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 (

View File

@ -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 = "."

View File

@ -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.

View File

@ -21,7 +21,6 @@
//
// cnf, err := config.NewConfig("yaml", "config.yaml")
//
// More docs http://beego.vip/docs/module/config.md
package yaml
import (

View File

@ -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))
}

View File

@ -30,7 +30,6 @@
// log.Debug("debug")
// log.Critical("critical")
//
// more docs http://beego.vip/docs/module/logs.md
package logs
import (

View File

@ -50,9 +50,5 @@ In your view templates:
</ul>
{{end}}
See also
http://beego.vip/docs/mvc/view/page.md
*/
package pagination

View File

@ -43,7 +43,6 @@
// }
// }
//
// more info: http://beego.vip/docs/mvc/controller/validation.md
package validation
import (

View File

@ -19,7 +19,6 @@
//
// ctx := context.Context{Request:req,ResponseWriter:rw}
//
// more docs http://beego.vip/docs/module/context.md
package context
import (

View File

@ -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.

View File

@ -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

View File

@ -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,

View File

@ -29,7 +29,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package couchbase
import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package memcache
import (

View File

@ -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"

View File

@ -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"

View File

@ -29,7 +29,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package redis
import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package redis_cluster
import (

View File

@ -24,7 +24,6 @@
// go globalSessions.GC()
// }
//
// more docs: http://beego.vip/docs/module/session.md
package session
import (

View File

@ -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...)
}

View File

@ -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