Skip to content

Commit 522b3a4

Browse files
authored
Merge pull request beego#2596 from astaxie/develop
beego 1.8.1
2 parents 323a1c4 + cd67f13 commit 522b3a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+556
-442
lines changed

.gosimpleignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
github.com/astaxie/beego/*/*:S1012
2+
github.com/astaxie/beego/*:S1012
3+
github.com/astaxie/beego/*/*:S1007
4+
github.com/astaxie/beego/*:S1007

.travis.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: go
22

33
go:
4-
- 1.6
5-
- 1.5.3
6-
- 1.4.3
4+
- 1.6.4
5+
- 1.7.5
6+
- 1.8.1
77
services:
88
- redis-server
99
- mysql
@@ -33,6 +33,8 @@ install:
3333
- go get github.com/ssdb/gossdb/ssdb
3434
- go get github.com/cloudflare/golz4
3535
- go get github.com/gogo/protobuf/proto
36+
- go get -u honnef.co/go/tools/cmd/gosimple
37+
- go get -u github.com/mdempsky/unconvert
3638
before_script:
3739
- psql --version
3840
- sh -c "if [ '$ORM_DRIVER' = 'postgres' ]; then psql -c 'create database orm_test;' -U postgres; fi"
@@ -47,5 +49,7 @@ after_script:
4749
- rm -rf ./res/var/*
4850
script:
4951
- go test -v ./...
52+
- gosimple -ignore "$(cat .gosimpleignore)" $(go list ./... | grep -v /vendor/)
53+
- unconvert $(go list ./... | grep -v /vendor/)
5054
addons:
5155
postgresql: "9.4"

README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
## Beego
2-
3-
[![Build Status](https://travis-ci.org/astaxie/beego.svg?branch=master)](https://travis-ci.org/astaxie/beego)
4-
[![GoDoc](http://godoc.org/github.com/astaxie/beego?status.svg)](http://godoc.org/github.com/astaxie/beego)
5-
[![Foundation](https://img.shields.io/badge/Golang-Foundation-green.svg)](http://golangfoundation.org)
1+
# Beego [![Build Status](https://travis-ci.org/astaxie/beego.svg?branch=master)](https://travis-ci.org/astaxie/beego) [![GoDoc](http://godoc.org/github.com/astaxie/beego?status.svg)](http://godoc.org/github.com/astaxie/beego) [![Foundation](https://img.shields.io/badge/Golang-Foundation-green.svg)](http://golangfoundation.org)
62

73
beego is used for rapid development of RESTful APIs, web apps and backend services in Go.
84
It is inspired by Tornado, Sinatra and Flask. beego has some Go-specific features such as interfaces and struct embedding.
95

10-
More info [beego.me](http://beego.me)
6+
###### More info at [beego.me](http://beego.me).
7+
8+
## Quick Start
119

12-
##Quick Start
13-
######Download and install
10+
#### Download and install
1411

1512
go get github.com/astaxie/beego
1613

17-
######Create file `hello.go`
14+
#### Create file `hello.go`
1815
```go
1916
package main
2017

@@ -24,15 +21,16 @@ func main(){
2421
beego.Run()
2522
}
2623
```
27-
######Build and run
28-
```bash
24+
#### Build and run
25+
2926
go build hello.go
3027
./hello
31-
```
32-
######Congratulations!
33-
You just built your first beego app.
34-
Open your browser and visit `http://localhost:8080`.
35-
Please see [Documentation](http://beego.me/docs) for more.
28+
29+
#### Go to [http://localhost:8080](http://localhost:8080)
30+
31+
Congratulations! You've just built your first **beego** app.
32+
33+
###### Please see [Documentation](http://beego.me/docs) for more.
3634

3735
## Features
3836

@@ -56,7 +54,7 @@ Please see [Documentation](http://beego.me/docs) for more.
5654
* [http://beego.me/community](http://beego.me/community)
5755
* Welcome to join us in Slack: [https://beego.slack.com](https://beego.slack.com), you can get invited from [here](https://github.com/beego/beedoc/issues/232)
5856

59-
## LICENSE
57+
## License
6058

6159
beego source code is licensed under the Apache Licence, Version 2.0
6260
(http://www.apache.org/licenses/LICENSE-2.0.html).

admin.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
157157
resultList := new([][]string)
158158
for _, f := range bf {
159159
var result = []string{
160-
fmt.Sprintf("%s", f.pattern),
161-
fmt.Sprintf("%s", utils.GetFuncName(f.filterFunc)),
160+
f.pattern,
161+
utils.GetFuncName(f.filterFunc),
162162
}
163163
*resultList = append(*resultList, result)
164164
}
@@ -208,12 +208,12 @@ func printTree(resultList *[][]string, t *Tree) {
208208
printTree(resultList, t.wildcard)
209209
}
210210
for _, l := range t.leaves {
211-
if v, ok := l.runObject.(*controllerInfo); ok {
211+
if v, ok := l.runObject.(*ControllerInfo); ok {
212212
if v.routerType == routerTypeBeego {
213213
var result = []string{
214214
v.pattern,
215215
fmt.Sprintf("%s", v.methods),
216-
fmt.Sprintf("%s", v.controllerType),
216+
v.controllerType.String(),
217217
}
218218
*resultList = append(*resultList, result)
219219
} else if v.routerType == routerTypeRESTFul {
@@ -276,8 +276,8 @@ func profIndex(rw http.ResponseWriter, r *http.Request) {
276276
// it's in "/healthcheck" pattern in admin module.
277277
func healthcheck(rw http.ResponseWriter, req *http.Request) {
278278
var (
279+
result []string
279280
data = make(map[interface{}]interface{})
280-
result = []string{}
281281
resultList = new([][]string)
282282
content = map[string]interface{}{
283283
"Fields": []string{"Name", "Message", "Status"},
@@ -287,21 +287,20 @@ func healthcheck(rw http.ResponseWriter, req *http.Request) {
287287
for name, h := range toolbox.AdminCheckList {
288288
if err := h.Check(); err != nil {
289289
result = []string{
290-
fmt.Sprintf("error"),
291-
fmt.Sprintf("%s", name),
292-
fmt.Sprintf("%s", err.Error()),
290+
"error",
291+
name,
292+
err.Error(),
293293
}
294-
295294
} else {
296295
result = []string{
297-
fmt.Sprintf("success"),
298-
fmt.Sprintf("%s", name),
299-
fmt.Sprintf("OK"),
296+
"success",
297+
name,
298+
"OK",
300299
}
301-
302300
}
303301
*resultList = append(*resultList, result)
304302
}
303+
305304
content["Data"] = resultList
306305
data["Content"] = content
307306
data["Title"] = "Health Check"
@@ -330,7 +329,6 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) {
330329
// List Tasks
331330
content := make(map[string]interface{})
332331
resultList := new([][]string)
333-
var result = []string{}
334332
var fields = []string{
335333
"Task Name",
336334
"Task Spec",
@@ -339,10 +337,10 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) {
339337
"",
340338
}
341339
for tname, tk := range toolbox.AdminTaskList {
342-
result = []string{
340+
result := []string{
343341
tname,
344-
fmt.Sprintf("%s", tk.GetSpec()),
345-
fmt.Sprintf("%s", tk.GetStatus()),
342+
tk.GetSpec(),
343+
tk.GetStatus(),
346344
tk.GetPrev().String(),
347345
}
348346
*resultList = append(*resultList, result)

app.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ func Any(rootpath string, f FilterFunc) *App {
348348

349349
// Handler used to register a Handler router
350350
// usage:
351-
// beego.Handler("/api", func(ctx *context.Context){
352-
// ctx.Output.Body("hello world")
353-
// })
351+
// beego.Handler("/api", http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
352+
// fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
353+
// }))
354354
func Handler(rootpath string, h http.Handler, options ...interface{}) *App {
355355
BeeApp.Handlers.Handler(rootpath, h, options...)
356356
return BeeApp

beego.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
const (
2525
// VERSION represent beego web framework version.
26-
VERSION = "1.8.0"
26+
VERSION = "1.8.1"
2727

2828
// DEV is for develop
2929
DEV = "dev"

cache/conv_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ func TestGetFloat64(t *testing.T) {
118118

119119
func TestGetBool(t *testing.T) {
120120
var t1 = true
121-
if true != GetBool(t1) {
121+
if !GetBool(t1) {
122122
t.Error("get bool from bool error")
123123
}
124124
var t2 = "true"
125-
if true != GetBool(t2) {
125+
if !GetBool(t2) {
126126
t.Error("get bool from string error")
127127
}
128-
if false != GetBool(nil) {
128+
if GetBool(nil) {
129129
t.Error("get bool from nil error")
130130
}
131131
}

cache/memcache/memcache.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,7 @@ func (rc *Cache) IsExist(key string) bool {
146146
}
147147
}
148148
_, err := rc.conn.Get(key)
149-
if err != nil {
150-
return false
151-
}
152-
return true
149+
return !(err != nil)
153150
}
154151

155152
// ClearAll clear all cached in memcache.

cache/redis/redis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (rc *Cache) IsExist(key string) bool {
137137
if err != nil {
138138
return false
139139
}
140-
if v == false {
140+
if !v {
141141
if _, err = rc.do("HDEL", rc.key, key); err != nil {
142142
return false
143143
}

cache/ssdb/ssdb.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (rc *Cache) GetMulti(keys []string) []interface{} {
5353
resSize := len(res)
5454
if err == nil {
5555
for i := 1; i < resSize; i += 2 {
56-
values = append(values, string(res[i+1]))
56+
values = append(values, res[i+1])
5757
}
5858
return values
5959
}
@@ -71,10 +71,7 @@ func (rc *Cache) DelMulti(keys []string) error {
7171
}
7272
}
7373
_, err := rc.conn.Do("multi_del", keys)
74-
if err != nil {
75-
return err
76-
}
77-
return nil
74+
return err
7875
}
7976

8077
// Put put value to memcache. only support string.
@@ -113,10 +110,7 @@ func (rc *Cache) Delete(key string) error {
113110
}
114111
}
115112
_, err := rc.conn.Del(key)
116-
if err != nil {
117-
return err
118-
}
119-
return nil
113+
return err
120114
}
121115

122116
// Incr increase counter.
@@ -175,7 +169,7 @@ func (rc *Cache) ClearAll() error {
175169
}
176170
keys := []string{}
177171
for i := 1; i < size; i += 2 {
178-
keys = append(keys, string(resp[i]))
172+
keys = append(keys, resp[i])
179173
}
180174
_, e := rc.conn.Do("multi_del", keys)
181175
if e != nil {
@@ -229,10 +223,7 @@ func (rc *Cache) connectInit() error {
229223
}
230224
var err error
231225
rc.conn, err = ssdb.Connect(host, port)
232-
if err != nil {
233-
return err
234-
}
235-
return nil
226+
return err
236227
}
237228

238229
func init() {

0 commit comments

Comments
 (0)