mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:10:55 +00:00
gofmt -s
This commit is contained in:
parent
90d1349665
commit
9adf20d72e
8
cache/file.go
vendored
8
cache/file.go
vendored
@ -39,10 +39,10 @@ type FileCacheItem struct {
|
|||||||
|
|
||||||
// FileCache Config
|
// FileCache Config
|
||||||
var (
|
var (
|
||||||
FileCachePath = "cache" // cache directory
|
FileCachePath = "cache" // cache directory
|
||||||
FileCacheFileSuffix = ".bin" // cache file suffix
|
FileCacheFileSuffix = ".bin" // cache file suffix
|
||||||
FileCacheDirectoryLevel = 2 // cache file deep level if auto generated cache files.
|
FileCacheDirectoryLevel = 2 // cache file deep level if auto generated cache files.
|
||||||
FileCacheEmbedExpiry time.Duration = 0 // cache expire time, default is no expire forever.
|
FileCacheEmbedExpiry time.Duration = 0 // cache expire time, default is no expire forever.
|
||||||
)
|
)
|
||||||
|
|
||||||
// FileCache is cache adapter for file storage.
|
// FileCache is cache adapter for file storage.
|
||||||
|
5
cache/memcache/memcache.go
vendored
5
cache/memcache/memcache.go
vendored
@ -36,8 +36,9 @@ import (
|
|||||||
|
|
||||||
"github.com/bradfitz/gomemcache/memcache"
|
"github.com/bradfitz/gomemcache/memcache"
|
||||||
|
|
||||||
"github.com/astaxie/beego/cache"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/astaxie/beego/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Cache Memcache adapter.
|
// Cache Memcache adapter.
|
||||||
@ -100,7 +101,7 @@ func (rc *Cache) Put(key string, val interface{}, timeout time.Duration) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("val must string")
|
return errors.New("val must string")
|
||||||
}
|
}
|
||||||
item := memcache.Item{Key: key, Value: []byte(v), Expiration: int32(timeout/time.Second)}
|
item := memcache.Item{Key: key, Value: []byte(v), Expiration: int32(timeout / time.Second)}
|
||||||
return rc.conn.Set(&item)
|
return rc.conn.Set(&item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
cache/memory.go
vendored
6
cache/memory.go
vendored
@ -86,9 +86,9 @@ func (bc *MemoryCache) Put(name string, value interface{}, lifespan time.Duratio
|
|||||||
bc.Lock()
|
bc.Lock()
|
||||||
defer bc.Unlock()
|
defer bc.Unlock()
|
||||||
bc.items[name] = &MemoryItem{
|
bc.items[name] = &MemoryItem{
|
||||||
val: value,
|
val: value,
|
||||||
createdTime: time.Now(),
|
createdTime: time.Now(),
|
||||||
lifespan: lifespan,
|
lifespan: lifespan,
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ func (bc *MemoryCache) StartAndGC(config string) error {
|
|||||||
cf = make(map[string]int)
|
cf = make(map[string]int)
|
||||||
cf["interval"] = DefaultEvery
|
cf["interval"] = DefaultEvery
|
||||||
}
|
}
|
||||||
dur := time.Duration(cf["interval"]) * time.Second
|
dur := time.Duration(cf["interval"]) * time.Second
|
||||||
bc.Every = cf["interval"]
|
bc.Every = cf["interval"]
|
||||||
bc.dur = dur
|
bc.dur = dur
|
||||||
go bc.vaccuum()
|
go bc.vaccuum()
|
||||||
|
@ -20,26 +20,25 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Test_ExtractEncoding(t *testing.T) {
|
func Test_ExtractEncoding(t *testing.T) {
|
||||||
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip,deflate"}}}) != "gzip" {
|
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"gzip,deflate"}}}) != "gzip" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"deflate,gzip"}}}) != "deflate" {
|
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"deflate,gzip"}}}) != "deflate" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=.5,deflate"}}}) != "deflate" {
|
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"gzip;q=.5,deflate"}}}) != "deflate" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=.5,deflate;q=0.3"}}}) != "gzip" {
|
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"gzip;q=.5,deflate;q=0.3"}}}) != "gzip" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"gzip;q=0,deflate"}}}) != "deflate" {
|
||||||
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=0,deflate"}}}) != "deflate" {
|
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"deflate;q=0.5,gzip;q=0.5,identity"}}}) != "" {
|
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"deflate;q=0.5,gzip;q=0.5,identity"}}}) != "" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"*"}}}) != "gzip" {
|
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"*"}}}) != "gzip" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,15 +118,15 @@ func NewServer(addr string, handler http.Handler) (srv *Server) {
|
|||||||
sigChan: make(chan os.Signal),
|
sigChan: make(chan os.Signal),
|
||||||
isChild: isChild,
|
isChild: isChild,
|
||||||
SignalHooks: map[int]map[os.Signal][]func(){
|
SignalHooks: map[int]map[os.Signal][]func(){
|
||||||
PreSignal: map[os.Signal][]func(){
|
PreSignal: {
|
||||||
syscall.SIGHUP: []func(){},
|
syscall.SIGHUP: {},
|
||||||
syscall.SIGINT: []func(){},
|
syscall.SIGINT: {},
|
||||||
syscall.SIGTERM: []func(){},
|
syscall.SIGTERM: {},
|
||||||
},
|
},
|
||||||
PostSignal: map[os.Signal][]func(){
|
PostSignal: {
|
||||||
syscall.SIGHUP: []func(){},
|
syscall.SIGHUP: {},
|
||||||
syscall.SIGINT: []func(){},
|
syscall.SIGINT: {},
|
||||||
syscall.SIGTERM: []func(){},
|
syscall.SIGTERM: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
state: StateInit,
|
state: StateInit,
|
||||||
|
@ -42,4 +42,3 @@ func TestConsole(t *testing.T) {
|
|||||||
log2.SetLogger("console", `{"level":3}`)
|
log2.SetLogger("console", `{"level":3}`)
|
||||||
testConsoleCalls(log2)
|
testConsoleCalls(log2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,6 @@ func BenchmarkFile(b *testing.B) {
|
|||||||
os.Remove("test4.log")
|
os.Remove("test4.log")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func BenchmarkFileAsynchronous(b *testing.B) {
|
func BenchmarkFileAsynchronous(b *testing.B) {
|
||||||
log := NewLogger(100000)
|
log := NewLogger(100000)
|
||||||
log.SetLogger("file", `{"filename":"test4.log"}`)
|
log.SetLogger("file", `{"filename":"test4.log"}`)
|
||||||
@ -168,7 +167,7 @@ func BenchmarkFileOnGoroutine(b *testing.B) {
|
|||||||
log := NewLogger(100000)
|
log := NewLogger(100000)
|
||||||
log.SetLogger("file", `{"filename":"test4.log"}`)
|
log.SetLogger("file", `{"filename":"test4.log"}`)
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
go log.Debug("debug")
|
go log.Debug("debug")
|
||||||
}
|
}
|
||||||
os.Remove("test4.log")
|
os.Remove("test4.log")
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ type ResourceListing struct {
|
|||||||
APIVersion string `json:"apiVersion"`
|
APIVersion string `json:"apiVersion"`
|
||||||
SwaggerVersion string `json:"swaggerVersion"` // e.g 1.2
|
SwaggerVersion string `json:"swaggerVersion"` // e.g 1.2
|
||||||
// BasePath string `json:"basePath"` obsolete in 1.1
|
// BasePath string `json:"basePath"` obsolete in 1.1
|
||||||
APIs []APIRef `json:"apis"`
|
APIs []APIRef `json:"apis"`
|
||||||
Info Information `json:"info"`
|
Info Information `json:"info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIRef description the api path and description
|
// APIRef description the api path and description
|
||||||
|
4
tree.go
4
tree.go
@ -141,7 +141,7 @@ func (t *Tree) addtree(segments []string, tree *Tree, wildcards []string, reg st
|
|||||||
regexpStr = "([^.]+).(.+)"
|
regexpStr = "([^.]+).(.+)"
|
||||||
params = params[1:]
|
params = params[1:]
|
||||||
} else {
|
} else {
|
||||||
for _ = range params {
|
for range params {
|
||||||
regexpStr = "([^/]+)/" + regexpStr
|
regexpStr = "([^/]+)/" + regexpStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string,
|
|||||||
regexpStr = "/([^.]+).(.+)"
|
regexpStr = "/([^.]+).(.+)"
|
||||||
params = params[1:]
|
params = params[1:]
|
||||||
} else {
|
} else {
|
||||||
for _ = range params {
|
for range params {
|
||||||
regexpStr = "/([^/]+)" + regexpStr
|
regexpStr = "/([^/]+)" + regexpStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user