ce332713 by 傅小黑

gofmt commented go files

1 parent b459cf23
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
10 "github.com/astaxie/beego/context" 10 "github.com/astaxie/beego/context"
11 ) 11 )
12 12
13 // FitlerFunc defines filter function type. 13 // FilterFunc defines filter function type.
14 type FilterFunc func(*context.Context) 14 type FilterFunc func(*context.Context)
15 15
16 // App defines beego application with a new PatternServeMux. 16 // App defines beego application with a new PatternServeMux.
......
...@@ -15,76 +15,76 @@ import ( ...@@ -15,76 +15,76 @@ import (
15 15
16 var ( 16 var (
17 // beego application 17 // beego application
18 BeeApp *App 18 BeeApp *App
19 // application configurations 19 // application configurations
20 AppName string 20 AppName string
21 AppPath string 21 AppPath string
22 AppConfigPath string 22 AppConfigPath string
23 StaticDir map[string]string 23 StaticDir map[string]string
24 // template caching map 24 // template caching map
25 TemplateCache map[string]*template.Template 25 TemplateCache map[string]*template.Template
26 // files with should be compressed with gzip (.js,.css,etc) 26 // files with should be compressed with gzip (.js,.css,etc)
27 StaticExtensionsToGzip []string 27 StaticExtensionsToGzip []string
28 // http server configurations 28 // http server configurations
29 HttpAddr string 29 HttpAddr string
30 HttpPort int 30 HttpPort int
31 HttpTLS bool 31 HttpTLS bool
32 HttpCertFile string 32 HttpCertFile string
33 HttpKeyFile string 33 HttpKeyFile string
34 // flag of auto recover panic 34 // flag of auto recover panic
35 RecoverPanic bool 35 RecoverPanic bool
36 // flag of render template automatically 36 // flag of render template automatically
37 AutoRender bool 37 AutoRender bool
38 ViewsPath string 38 ViewsPath string
39 // run mode, "dev" or "prod" 39 // run mode, "dev" or "prod"
40 RunMode string 40 RunMode string
41 AppConfig config.ConfigContainer 41 AppConfig config.ConfigContainer
42 // global session mananger 42 // global session mananger
43 GlobalSessions *session.Manager 43 GlobalSessions *session.Manager
44 // flag of starting session auto. default is false. 44 // flag of starting session auto. default is false.
45 SessionOn bool 45 SessionOn bool
46 // default session provider, memory, mysql , redis ,etc. 46 // default session provider, memory, mysql , redis ,etc.
47 SessionProvider string 47 SessionProvider string
48 // the cookie name when saving session id into cookie. 48 // the cookie name when saving session id into cookie.
49 SessionName string 49 SessionName string
50 // session gc time for auto cleaning expired session. 50 // session gc time for auto cleaning expired session.
51 SessionGCMaxLifetime int64 51 SessionGCMaxLifetime int64
52 // if use mysql/redis/file provider, define save path to connection info. 52 // if use mysql/redis/file provider, define save path to connection info.
53 SessionSavePath string 53 SessionSavePath string
54 // session hash generation func. 54 // session hash generation func.
55 SessionHashFunc string 55 SessionHashFunc string
56 // session hash salt string. 56 // session hash salt string.
57 SessionHashKey string 57 SessionHashKey string
58 // the life time of session id in cookie. 58 // the life time of session id in cookie.
59 SessionCookieLifeTime int 59 SessionCookieLifeTime int
60 UseFcgi bool 60 UseFcgi bool
61 MaxMemory int64 61 MaxMemory int64
62 // flag of enable gzip 62 // flag of enable gzip
63 EnableGzip bool 63 EnableGzip bool
64 // flag of display directory index. default is false. 64 // flag of display directory index. default is false.
65 DirectoryIndex bool 65 DirectoryIndex bool
66 // flag of hot update checking in app self. default is false. 66 // flag of hot update checking in app self. default is false.
67 EnableHotUpdate bool 67 EnableHotUpdate bool
68 HttpServerTimeOut int64 68 HttpServerTimeOut int64
69 // flag of show errors in page. if true, show error and trace info in page rendered with error template. 69 // flag of show errors in page. if true, show error and trace info in page rendered with error template.
70 ErrorsShow bool 70 ErrorsShow bool
71 // xsrf hash salt string. 71 // xsrf hash salt string.
72 XSRFKEY string 72 XSRFKEY string
73 // flag of enable xsrf. 73 // flag of enable xsrf.
74 EnableXSRF bool 74 EnableXSRF bool
75 // the expiry of xsrf value. 75 // the expiry of xsrf value.
76 XSRFExpire int 76 XSRFExpire int
77 // flag of copy raw request body in context. 77 // flag of copy raw request body in context.
78 CopyRequestBody bool 78 CopyRequestBody bool
79 TemplateLeft string 79 TemplateLeft string
80 TemplateRight string 80 TemplateRight string
81 // beego server name exported in response header. 81 // beego server name exported in response header.
82 BeegoServerName string 82 BeegoServerName string
83 // flag of enable admin module to log every request info. 83 // flag of enable admin module to log every request info.
84 EnableAdmin bool 84 EnableAdmin bool
85 // http server configurations for admin module. 85 // http server configurations for admin module.
86 AdminHttpAddr string 86 AdminHttpAddr string
87 AdminHttpPort int 87 AdminHttpPort int
88 ) 88 )
89 89
90 func init() { 90 func init() {
...@@ -127,7 +127,7 @@ func init() { ...@@ -127,7 +127,7 @@ func init() {
127 127
128 UseFcgi = false 128 UseFcgi = false
129 129
130 MaxMemory = 1<<26 //64MB 130 MaxMemory = 1 << 26 //64MB
131 131
132 EnableGzip = false 132 EnableGzip = false
133 133
......
...@@ -144,15 +144,15 @@ func (c *Controller) RenderBytes() ([]byte, error) { ...@@ -144,15 +144,15 @@ func (c *Controller) RenderBytes() ([]byte, error) {
144 //if the controller has set layout, then first get the tplname's content set the content to the layout 144 //if the controller has set layout, then first get the tplname's content set the content to the layout
145 if c.Layout != "" { 145 if c.Layout != "" {
146 if c.TplNames == "" { 146 if c.TplNames == "" {
147 c.TplNames = strings.ToLower(c.controllerName)+"/"+strings.ToLower(c.actionName)+"." + c.TplExt 147 c.TplNames = strings.ToLower(c.controllerName) + "/" + strings.ToLower(c.actionName) + "." + c.TplExt
148 } 148 }
149 if RunMode == "dev" { 149 if RunMode == "dev" {
150 BuildTemplate(ViewsPath) 150 BuildTemplate(ViewsPath)
151 } 151 }
152 newbytes := bytes.NewBufferString("") 152 newbytes := bytes.NewBufferString("")
153 if _, ok := BeeTemplates[c.TplNames]; !ok { 153 if _, ok := BeeTemplates[c.TplNames]; !ok {
154 panic("can't find templatefile in the path:"+c.TplNames) 154 panic("can't find templatefile in the path:" + c.TplNames)
155 return []byte{}, errors.New("can't find templatefile in the path:"+c.TplNames) 155 return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
156 } 156 }
157 err := BeeTemplates[c.TplNames].ExecuteTemplate(newbytes, c.TplNames, c.Data) 157 err := BeeTemplates[c.TplNames].ExecuteTemplate(newbytes, c.TplNames, c.Data)
158 if err != nil { 158 if err != nil {
...@@ -171,15 +171,15 @@ func (c *Controller) RenderBytes() ([]byte, error) { ...@@ -171,15 +171,15 @@ func (c *Controller) RenderBytes() ([]byte, error) {
171 return icontent, nil 171 return icontent, nil
172 } else { 172 } else {
173 if c.TplNames == "" { 173 if c.TplNames == "" {
174 c.TplNames = strings.ToLower(c.controllerName)+"/"+strings.ToLower(c.actionName)+"." + c.TplExt 174 c.TplNames = strings.ToLower(c.controllerName) + "/" + strings.ToLower(c.actionName) + "." + c.TplExt
175 } 175 }
176 if RunMode == "dev" { 176 if RunMode == "dev" {
177 BuildTemplate(ViewsPath) 177 BuildTemplate(ViewsPath)
178 } 178 }
179 ibytes := bytes.NewBufferString("") 179 ibytes := bytes.NewBufferString("")
180 if _, ok := BeeTemplates[c.TplNames]; !ok { 180 if _, ok := BeeTemplates[c.TplNames]; !ok {
181 panic("can't find templatefile in the path:"+c.TplNames) 181 panic("can't find templatefile in the path:" + c.TplNames)
182 return []byte{}, errors.New("can't find templatefile in the path:"+c.TplNames) 182 return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
183 } 183 }
184 err := BeeTemplates[c.TplNames].ExecuteTemplate(ibytes, c.TplNames, c.Data) 184 err := BeeTemplates[c.TplNames].ExecuteTemplate(ibytes, c.TplNames, c.Data)
185 if err != nil { 185 if err != nil {
...@@ -219,7 +219,7 @@ func (c *Controller) UrlFor(endpoint string, values ...string) string { ...@@ -219,7 +219,7 @@ func (c *Controller) UrlFor(endpoint string, values ...string) string {
219 return "" 219 return ""
220 } 220 }
221 if endpoint[0] == '.' { 221 if endpoint[0] == '.' {
222 return UrlFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name() + endpoint, values...) 222 return UrlFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name()+endpoint, values...)
223 } else { 223 } else {
224 return UrlFor(endpoint, values...) 224 return UrlFor(endpoint, values...)
225 } 225 }
...@@ -327,7 +327,7 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error { ...@@ -327,7 +327,7 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error {
327 return err 327 return err
328 } 328 }
329 defer file.Close() 329 defer file.Close()
330 f, err := os.OpenFile(tofile, os.O_WRONLY | os.O_CREATE | os.O_TRUNC, 0666) 330 f, err := os.OpenFile(tofile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
331 if err != nil { 331 if err != nil {
332 return err 332 return err
333 } 333 }
...@@ -464,7 +464,7 @@ func (c *Controller) CheckXsrfCookie() bool { ...@@ -464,7 +464,7 @@ func (c *Controller) CheckXsrfCookie() bool {
464 // XsrfFormHtml writes an input field contains xsrf token value. 464 // XsrfFormHtml writes an input field contains xsrf token value.
465 func (c *Controller) XsrfFormHtml() string { 465 func (c *Controller) XsrfFormHtml() string {
466 return "<input type=\"hidden\" name=\"_xsrf\" value=\"" + 466 return "<input type=\"hidden\" name=\"_xsrf\" value=\"" +
467 c._xsrf_token + "\"/>" 467 c._xsrf_token + "\"/>"
468 } 468 }
469 469
470 // GetControllerAndAction gets the executing controller name and action name. 470 // GetControllerAndAction gets the executing controller name and action name.
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!