42455216 by astaxie

fix #576

1 parent 05e5baaa
...@@ -232,7 +232,7 @@ func runTask(rw http.ResponseWriter, req *http.Request) { ...@@ -232,7 +232,7 @@ func runTask(rw http.ResponseWriter, req *http.Request) {
232 if err != nil { 232 if err != nil {
233 fmt.Fprintf(rw, "%v", err) 233 fmt.Fprintf(rw, "%v", err)
234 } 234 }
235 fmt.Fprintf(rw, "%s run success,Now the Status is %s", t.GetStatus()) 235 fmt.Fprintf(rw, "%s run success,Now the Status is %s", taskname, t.GetStatus())
236 } else { 236 } else {
237 fmt.Fprintf(rw, "there's no task which named:%s", taskname) 237 fmt.Fprintf(rw, "there's no task which named:%s", taskname)
238 } 238 }
......
...@@ -105,7 +105,6 @@ func (rc *MemcacheCache) IsExist(key string) bool { ...@@ -105,7 +105,6 @@ func (rc *MemcacheCache) IsExist(key string) bool {
105 } else { 105 } else {
106 return true 106 return true
107 } 107 }
108 return true
109 } 108 }
110 109
111 // clear all cached in memcache. 110 // clear all cached in memcache.
......
...@@ -53,7 +53,6 @@ func (c *JsonConfigContainer) Bool(key string) (bool, error) { ...@@ -53,7 +53,6 @@ func (c *JsonConfigContainer) Bool(key string) (bool, error) {
53 } else { 53 } else {
54 return false, errors.New("not exist key:" + key) 54 return false, errors.New("not exist key:" + key)
55 } 55 }
56 return false, nil
57 } 56 }
58 57
59 // Int returns the integer value for a given key. 58 // Int returns the integer value for a given key.
...@@ -68,7 +67,6 @@ func (c *JsonConfigContainer) Int(key string) (int, error) { ...@@ -68,7 +67,6 @@ func (c *JsonConfigContainer) Int(key string) (int, error) {
68 } else { 67 } else {
69 return 0, errors.New("not exist key:" + key) 68 return 0, errors.New("not exist key:" + key)
70 } 69 }
71 return 0, nil
72 } 70 }
73 71
74 // Int64 returns the int64 value for a given key. 72 // Int64 returns the int64 value for a given key.
...@@ -83,7 +81,6 @@ func (c *JsonConfigContainer) Int64(key string) (int64, error) { ...@@ -83,7 +81,6 @@ func (c *JsonConfigContainer) Int64(key string) (int64, error) {
83 } else { 81 } else {
84 return 0, errors.New("not exist key:" + key) 82 return 0, errors.New("not exist key:" + key)
85 } 83 }
86 return 0, nil
87 } 84 }
88 85
89 // Float returns the float value for a given key. 86 // Float returns the float value for a given key.
...@@ -98,7 +95,6 @@ func (c *JsonConfigContainer) Float(key string) (float64, error) { ...@@ -98,7 +95,6 @@ func (c *JsonConfigContainer) Float(key string) (float64, error) {
98 } else { 95 } else {
99 return 0.0, errors.New("not exist key:" + key) 96 return 0.0, errors.New("not exist key:" + key)
100 } 97 }
101 return 0.0, nil
102 } 98 }
103 99
104 // String returns the string value for a given key. 100 // String returns the string value for a given key.
...@@ -113,7 +109,6 @@ func (c *JsonConfigContainer) String(key string) string { ...@@ -113,7 +109,6 @@ func (c *JsonConfigContainer) String(key string) string {
113 } else { 109 } else {
114 return "" 110 return ""
115 } 111 }
116 return ""
117 } 112 }
118 113
119 // Strings returns the []string value for a given key. 114 // Strings returns the []string value for a given key.
...@@ -137,7 +132,6 @@ func (c *JsonConfigContainer) DIY(key string) (v interface{}, err error) { ...@@ -137,7 +132,6 @@ func (c *JsonConfigContainer) DIY(key string) (v interface{}, err error) {
137 } else { 132 } else {
138 return nil, errors.New("not exist key") 133 return nil, errors.New("not exist key")
139 } 134 }
140 return nil, nil
141 } 135 }
142 136
143 // section.key or key 137 // section.key or key
......
...@@ -153,7 +153,6 @@ func (c *Controller) RenderBytes() ([]byte, error) { ...@@ -153,7 +153,6 @@ func (c *Controller) RenderBytes() ([]byte, error) {
153 newbytes := bytes.NewBufferString("") 153 newbytes := bytes.NewBufferString("")
154 if _, ok := BeeTemplates[c.TplNames]; !ok { 154 if _, ok := BeeTemplates[c.TplNames]; !ok {
155 panic("can't find templatefile in the path:" + c.TplNames) 155 panic("can't find templatefile in the path:" + c.TplNames)
156 return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
157 } 156 }
158 err := BeeTemplates[c.TplNames].ExecuteTemplate(newbytes, c.TplNames, c.Data) 157 err := BeeTemplates[c.TplNames].ExecuteTemplate(newbytes, c.TplNames, c.Data)
159 if err != nil { 158 if err != nil {
...@@ -199,7 +198,6 @@ func (c *Controller) RenderBytes() ([]byte, error) { ...@@ -199,7 +198,6 @@ func (c *Controller) RenderBytes() ([]byte, error) {
199 ibytes := bytes.NewBufferString("") 198 ibytes := bytes.NewBufferString("")
200 if _, ok := BeeTemplates[c.TplNames]; !ok { 199 if _, ok := BeeTemplates[c.TplNames]; !ok {
201 panic("can't find templatefile in the path:" + c.TplNames) 200 panic("can't find templatefile in the path:" + c.TplNames)
202 return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
203 } 201 }
204 err := BeeTemplates[c.TplNames].ExecuteTemplate(ibytes, c.TplNames, c.Data) 202 err := BeeTemplates[c.TplNames].ExecuteTemplate(ibytes, c.TplNames, c.Data)
205 if err != nil { 203 if err != nil {
...@@ -209,7 +207,6 @@ func (c *Controller) RenderBytes() ([]byte, error) { ...@@ -209,7 +207,6 @@ func (c *Controller) RenderBytes() ([]byte, error) {
209 icontent, _ := ioutil.ReadAll(ibytes) 207 icontent, _ := ioutil.ReadAll(ibytes)
210 return icontent, nil 208 return icontent, nil
211 } 209 }
212 return []byte{}, nil
213 } 210 }
214 211
215 // Redirect sends the redirection response to url with status code. 212 // Redirect sends the redirection response to url with status code.
...@@ -243,7 +240,6 @@ func (c *Controller) UrlFor(endpoint string, values ...string) string { ...@@ -243,7 +240,6 @@ func (c *Controller) UrlFor(endpoint string, values ...string) string {
243 } else { 240 } else {
244 return UrlFor(endpoint, values...) 241 return UrlFor(endpoint, values...)
245 } 242 }
246 return ""
247 } 243 }
248 244
249 // ServeJson sends a json response with encoding charset. 245 // ServeJson sends a json response with encoding charset.
......
...@@ -30,7 +30,7 @@ type FileLogWriter struct { ...@@ -30,7 +30,7 @@ type FileLogWriter struct {
30 30
31 // Rotate daily 31 // Rotate daily
32 Daily bool `json:"daily"` 32 Daily bool `json:"daily"`
33 Maxdays int64 `json:"maxdays` 33 Maxdays int64 `json:"maxdays"`
34 daily_opendate int 34 daily_opendate int
35 35
36 Rotate bool `json:"rotate"` 36 Rotate bool `json:"rotate"`
......
...@@ -195,5 +195,4 @@ func getAcceptEncodingZip(r *http.Request) string { ...@@ -195,5 +195,4 @@ func getAcceptEncodingZip(r *http.Request) string {
195 } else { 195 } else {
196 return "" 196 return ""
197 } 197 }
198 return ""
199 } 198 }
......
...@@ -446,7 +446,6 @@ func (d *dbBase) Update(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time. ...@@ -446,7 +446,6 @@ func (d *dbBase) Update(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time.
446 } else { 446 } else {
447 return 0, err 447 return 0, err
448 } 448 }
449 return 0, nil
450 } 449 }
451 450
452 // execute delete sql dbQuerier with given struct reflect.Value. 451 // execute delete sql dbQuerier with given struct reflect.Value.
...@@ -489,7 +488,6 @@ func (d *dbBase) Delete(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time. ...@@ -489,7 +488,6 @@ func (d *dbBase) Delete(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time.
489 } else { 488 } else {
490 return 0, err 489 return 0, err
491 } 490 }
492 return 0, nil
493 } 491 }
494 492
495 // update table-related record by querySet. 493 // update table-related record by querySet.
...@@ -566,7 +564,6 @@ func (d *dbBase) UpdateBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con ...@@ -566,7 +564,6 @@ func (d *dbBase) UpdateBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
566 } else { 564 } else {
567 return 0, err 565 return 0, err
568 } 566 }
569 return 0, nil
570 } 567 }
571 568
572 // delete related records. 569 // delete related records.
...@@ -671,8 +668,6 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con ...@@ -671,8 +668,6 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
671 } else { 668 } else {
672 return 0, err 669 return 0, err
673 } 670 }
674
675 return 0, nil
676 } 671 }
677 672
678 // read related records. 673 // read related records.
......
...@@ -13,7 +13,6 @@ func getDbAlias(name string) *alias { ...@@ -13,7 +13,6 @@ func getDbAlias(name string) *alias {
13 } else { 13 } else {
14 panic(fmt.Errorf("unknown DataBase alias name %s", name)) 14 panic(fmt.Errorf("unknown DataBase alias name %s", name))
15 } 15 }
16 return nil
17 } 16 }
18 17
19 // get pk column info. 18 // get pk column info.
......
...@@ -83,7 +83,6 @@ func (e *JsonField) SetRaw(value interface{}) error { ...@@ -83,7 +83,6 @@ func (e *JsonField) SetRaw(value interface{}) error {
83 default: 83 default:
84 return fmt.Errorf("<JsonField.SetRaw> unknown value `%v`", value) 84 return fmt.Errorf("<JsonField.SetRaw> unknown value `%v`", value)
85 } 85 }
86 return nil
87 } 86 }
88 87
89 func (e *JsonField) RawValue() interface{} { 88 func (e *JsonField) RawValue() interface{} {
...@@ -122,7 +121,7 @@ type DataNull struct { ...@@ -122,7 +121,7 @@ type DataNull struct {
122 Char string `orm:"null;size(50)"` 121 Char string `orm:"null;size(50)"`
123 Text string `orm:"null;type(text)"` 122 Text string `orm:"null;type(text)"`
124 Date time.Time `orm:"null;type(date)"` 123 Date time.Time `orm:"null;type(date)"`
125 DateTime time.Time `orm:"null;column(datetime)""` 124 DateTime time.Time `orm:"null;column(datetime)"`
126 Byte byte `orm:"null"` 125 Byte byte `orm:"null"`
127 Rune rune `orm:"null"` 126 Rune rune `orm:"null"`
128 Int int `orm:"null"` 127 Int int `orm:"null"`
......
...@@ -293,7 +293,7 @@ func (o *orm) queryRelated(md interface{}, name string) (*modelInfo, *fieldInfo, ...@@ -293,7 +293,7 @@ func (o *orm) queryRelated(md interface{}, name string) (*modelInfo, *fieldInfo,
293 } 293 }
294 294
295 if qs == nil { 295 if qs == nil {
296 panic(fmt.Errorf("<Ormer> name `%s` for model `%s` is not an available rel/reverse field")) 296 panic(fmt.Errorf("<Ormer> name `%s` for model `%s` is not an available rel/reverse field", md, name))
297 } 297 }
298 298
299 return mi, fi, ind, qs 299 return mi, fi, ind, qs
...@@ -441,8 +441,6 @@ func (o *orm) Driver() Driver { ...@@ -441,8 +441,6 @@ func (o *orm) Driver() Driver {
441 441
442 func (o *orm) GetDB() dbQuerier { 442 func (o *orm) GetDB() dbQuerier {
443 panic(ErrNotImplement) 443 panic(ErrNotImplement)
444 // not enough
445 return o.db
446 } 444 }
447 445
448 // create new orm 446 // create new orm
......
...@@ -209,7 +209,6 @@ func (o *querySet) ValuesFlat(result *ParamsList, expr string) (int64, error) { ...@@ -209,7 +209,6 @@ func (o *querySet) ValuesFlat(result *ParamsList, expr string) (int64, error) {
209 // } 209 // }
210 func (o *querySet) RowsToMap(result *Params, keyCol, valueCol string) (int64, error) { 210 func (o *querySet) RowsToMap(result *Params, keyCol, valueCol string) (int64, error) {
211 panic(ErrNotImplement) 211 panic(ErrNotImplement)
212 return o.orm.alias.DbBaser.RowsTo(o.orm.db, o, o.mi, o.cond, result, keyCol, valueCol, o.orm.alias.TZ)
213 } 212 }
214 213
215 // query all rows into struct with specify key and value column name. 214 // query all rows into struct with specify key and value column name.
...@@ -224,7 +223,6 @@ func (o *querySet) RowsToMap(result *Params, keyCol, valueCol string) (int64, er ...@@ -224,7 +223,6 @@ func (o *querySet) RowsToMap(result *Params, keyCol, valueCol string) (int64, er
224 // } 223 // }
225 func (o *querySet) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error) { 224 func (o *querySet) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error) {
226 panic(ErrNotImplement) 225 panic(ErrNotImplement)
227 return o.orm.alias.DbBaser.RowsTo(o.orm.db, o, o.mi, o.cond, ptrStruct, keyCol, valueCol, o.orm.alias.TZ)
228 } 226 }
229 227
230 // create new QuerySeter. 228 // create new QuerySeter.
......
...@@ -282,10 +282,10 @@ func TestNullDataTypes(t *testing.T) { ...@@ -282,10 +282,10 @@ func TestNullDataTypes(t *testing.T) {
282 282
283 d = DataNull{ 283 d = DataNull{
284 DateTime: time.Now(), 284 DateTime: time.Now(),
285 NullString: sql.NullString{"test", true}, 285 NullString: sql.NullString{String: "test", Valid: true},
286 NullBool: sql.NullBool{true, true}, 286 NullBool: sql.NullBool{Bool: true, Valid: true},
287 NullInt64: sql.NullInt64{42, true}, 287 NullInt64: sql.NullInt64{Int64: 42, Valid: true},
288 NullFloat64: sql.NullFloat64{42.42, true}, 288 NullFloat64: sql.NullFloat64{Float64: 42.42, Valid: true},
289 } 289 }
290 290
291 id, err = dORM.Insert(&d) 291 id, err = dORM.Insert(&d)
......
...@@ -266,5 +266,4 @@ func indirectType(v reflect.Type) reflect.Type { ...@@ -266,5 +266,4 @@ func indirectType(v reflect.Type) reflect.Type {
266 default: 266 default:
267 return v 267 return v
268 } 268 }
269 return v
270 } 269 }
......
...@@ -29,7 +29,7 @@ type conn struct { ...@@ -29,7 +29,7 @@ type conn struct {
29 net.Conn 29 net.Conn
30 wg *sync.WaitGroup 30 wg *sync.WaitGroup
31 isclose bool 31 isclose bool
32 lock sync.Mutex 32 lock *sync.Mutex
33 } 33 }
34 34
35 // Close current processing connection. 35 // Close current processing connection.
...@@ -102,7 +102,6 @@ func WaitSignal(l net.Listener) error { ...@@ -102,7 +102,6 @@ func WaitSignal(l net.Listener) error {
102 return nil 102 return nil
103 } 103 }
104 } 104 }
105 return nil // It'll never get here.
106 } 105 }
107 106
108 // Kill current running os process. 107 // Kill current running os process.
......
...@@ -216,7 +216,6 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM ...@@ -216,7 +216,6 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
216 if regexErr != nil { 216 if regexErr != nil {
217 //TODO add error handling here to avoid panic 217 //TODO add error handling here to avoid panic
218 panic(regexErr) 218 panic(regexErr)
219 return
220 } 219 }
221 220
222 //now create the Route 221 //now create the Route
......
...@@ -43,7 +43,6 @@ func (cs *CouchbaseSessionStore) Get(key interface{}) interface{} { ...@@ -43,7 +43,6 @@ func (cs *CouchbaseSessionStore) Get(key interface{}) interface{} {
43 } else { 43 } else {
44 return nil 44 return nil
45 } 45 }
46 return nil
47 } 46 }
48 47
49 func (cs *CouchbaseSessionStore) Delete(key interface{}) error { 48 func (cs *CouchbaseSessionStore) Delete(key interface{}) error {
......
...@@ -47,7 +47,6 @@ func (st *MysqlSessionStore) Get(key interface{}) interface{} { ...@@ -47,7 +47,6 @@ func (st *MysqlSessionStore) Get(key interface{}) interface{} {
47 } else { 47 } else {
48 return nil 48 return nil
49 } 49 }
50 return nil
51 } 50 }
52 51
53 // delete value in mysql session 52 // delete value in mysql session
......
...@@ -68,7 +68,6 @@ func (st *PostgresqlSessionStore) Get(key interface{}) interface{} { ...@@ -68,7 +68,6 @@ func (st *PostgresqlSessionStore) Get(key interface{}) interface{} {
68 } else { 68 } else {
69 return nil 69 return nil
70 } 70 }
71 return nil
72 } 71 }
73 72
74 // delete value in postgresql session 73 // delete value in postgresql session
......
...@@ -44,7 +44,6 @@ func (rs *RedisSessionStore) Get(key interface{}) interface{} { ...@@ -44,7 +44,6 @@ func (rs *RedisSessionStore) Get(key interface{}) interface{} {
44 } else { 44 } else {
45 return nil 45 return nil
46 } 46 }
47 return nil
48 } 47 }
49 48
50 // delete value in redis session 49 // delete value in redis session
......
...@@ -36,7 +36,6 @@ func (st *CookieSessionStore) Get(key interface{}) interface{} { ...@@ -36,7 +36,6 @@ func (st *CookieSessionStore) Get(key interface{}) interface{} {
36 } else { 36 } else {
37 return nil 37 return nil
38 } 38 }
39 return nil
40 } 39 }
41 40
42 // Delete value in cookie session 41 // Delete value in cookie session
......
...@@ -43,7 +43,6 @@ func (fs *FileSessionStore) Get(key interface{}) interface{} { ...@@ -43,7 +43,6 @@ func (fs *FileSessionStore) Get(key interface{}) interface{} {
43 } else { 43 } else {
44 return nil 44 return nil
45 } 45 }
46 return nil
47 } 46 }
48 47
49 // Delete value in file session by given key 48 // Delete value in file session by given key
......
...@@ -35,7 +35,6 @@ func (st *MemSessionStore) Get(key interface{}) interface{} { ...@@ -35,7 +35,6 @@ func (st *MemSessionStore) Get(key interface{}) interface{} {
35 } else { 35 } else {
36 return nil 36 return nil
37 } 37 }
38 return nil
39 } 38 }
40 39
41 // delete in memory session by key 40 // delete in memory session by key
...@@ -94,7 +93,6 @@ func (pder *MemProvider) SessionRead(sid string) (SessionStore, error) { ...@@ -94,7 +93,6 @@ func (pder *MemProvider) SessionRead(sid string) (SessionStore, error) {
94 pder.lock.Unlock() 93 pder.lock.Unlock()
95 return newsess, nil 94 return newsess, nil
96 } 95 }
97 return nil, nil
98 } 96 }
99 97
100 // check session store exist in memory session by sid 98 // check session store exist in memory session by sid
...@@ -129,7 +127,6 @@ func (pder *MemProvider) SessionRegenerate(oldsid, sid string) (SessionStore, er ...@@ -129,7 +127,6 @@ func (pder *MemProvider) SessionRegenerate(oldsid, sid string) (SessionStore, er
129 pder.lock.Unlock() 127 pder.lock.Unlock()
130 return newsess, nil 128 return newsess, nil
131 } 129 }
132 return nil, nil
133 } 130 }
134 131
135 // delete session store in memory session by id 132 // delete session store in memory session by id
......
...@@ -164,8 +164,6 @@ func decodeCookie(block cipher.Block, hashKey, name, value string, gcmaxlifetime ...@@ -164,8 +164,6 @@ func decodeCookie(block cipher.Block, hashKey, name, value string, gcmaxlifetime
164 } else { 164 } else {
165 return dst, nil 165 return dst, nil
166 } 166 }
167 // Done.
168 return nil, nil
169 } 167 }
170 168
171 // Encoding ------------------------------------------------------------------- 169 // Encoding -------------------------------------------------------------------
......
...@@ -48,7 +48,7 @@ func ProcessInput(input string, w io.Writer) { ...@@ -48,7 +48,7 @@ func ProcessInput(input string, w io.Writer) {
48 // record memory profile in pprof 48 // record memory profile in pprof
49 func MemProf() { 49 func MemProf() {
50 if f, err := os.Create("mem-" + strconv.Itoa(pid) + ".memprof"); err != nil { 50 if f, err := os.Create("mem-" + strconv.Itoa(pid) + ".memprof"); err != nil {
51 log.Fatal("record memory profile failed: %v", err) 51 log.Fatal("record memory profile failed: ", err)
52 } else { 52 } else {
53 runtime.GC() 53 runtime.GC()
54 pprof.WriteHeapProfile(f) 54 pprof.WriteHeapProfile(f)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!