Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e930b9

Browse files
lint code
1 parent 89f1adf commit 9e930b9

File tree

17 files changed

+72
-73
lines changed

17 files changed

+72
-73
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<img align="right" src="https://raw.githubusercontent.com/gin-gonic/gin/master/logo.jpg">
44
[![Build Status](https://travis-ci.org/gin-gonic/gin.svg)](https://travis-ci.org/gin-gonic/gin)
55
[![Coverage Status](https://coveralls.io/repos/gin-gonic/gin/badge.svg?branch=master)](https://coveralls.io/r/gin-gonic/gin?branch=master)
6-
[![Go Report Card](https://goreportcard.com/badge/github.com/gin-gonic/gin)]
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/gin-gonic/gin)](https://goreportcard.com/report/github.com/gin-gonic/gin)
77
[![GoDoc](https://godoc.org/github.com/gin-gonic/gin?status.svg)](https://godoc.org/github.com/gin-gonic/gin)
88
[![Join the chat at https://gitter.im/gin-gonic/gin](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gin-gonic/gin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
99

binding/protobuf.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import (
1313

1414
type protobufBinding struct{}
1515

16-
func (_ protobufBinding) Name() string {
16+
func (protobufBinding) Name() string {
1717
return "protobuf"
1818
}
1919

20-
func (_ protobufBinding) Bind(req *http.Request, obj interface{}) error {
20+
func (protobufBinding) Bind(req *http.Request, obj interface{}) error {
2121

2222
buf, err := ioutil.ReadAll(req.Body)
2323
if err != nil {

binding/validate_test.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ type testInterface interface {
1616
String() string
1717
}
1818

19-
type substruct_noValidation struct {
20-
I_String string
21-
I_Int int
19+
type substructNoValidation struct {
20+
IString string
21+
IInt int
2222
}
2323

24-
type mapNoValidationSub map[string]substruct_noValidation
24+
type mapNoValidationSub map[string]substructNoValidation
2525

26-
type struct_noValidation_values struct {
27-
substruct_noValidation
26+
type structNoValidationValues struct {
27+
substructNoValidation
2828

2929
Boolean bool
3030

@@ -46,16 +46,16 @@ type struct_noValidation_values struct {
4646

4747
Date time.Time
4848

49-
Struct substruct_noValidation
49+
Struct substructNoValidation
5050
InlinedStruct struct {
5151
String []string
5252
Integer int
5353
}
5454

5555
IntSlice []int
5656
IntPointerSlice []*int
57-
StructPointerSlice []*substruct_noValidation
58-
StructSlice []substruct_noValidation
57+
StructPointerSlice []*substructNoValidation
58+
StructSlice []substructNoValidation
5959
InterfaceSlice []testInterface
6060

6161
UniversalInterface interface{}
@@ -65,9 +65,9 @@ type struct_noValidation_values struct {
6565
StructMap mapNoValidationSub
6666
}
6767

68-
func createNoValidation_values() struct_noValidation_values {
68+
func createNoValidationValues() structNoValidationValues {
6969
integer := 1
70-
s := struct_noValidation_values{
70+
s := structNoValidationValues{
7171
Boolean: true,
7272
Uinteger: 1 << 29,
7373
Integer: -10000,
@@ -84,33 +84,33 @@ func createNoValidation_values() struct_noValidation_values {
8484
String: "text",
8585
Date: time.Time{},
8686
CustomInterface: &bytes.Buffer{},
87-
Struct: substruct_noValidation{},
87+
Struct: substructNoValidation{},
8888
IntSlice: []int{-3, -2, 1, 0, 1, 2, 3},
8989
IntPointerSlice: []*int{&integer},
90-
StructSlice: []substruct_noValidation{},
90+
StructSlice: []substructNoValidation{},
9191
UniversalInterface: 1.2,
9292
FloatMap: map[string]float32{
9393
"foo": 1.23,
9494
"bar": 232.323,
9595
},
9696
StructMap: mapNoValidationSub{
97-
"foo": substruct_noValidation{},
98-
"bar": substruct_noValidation{},
97+
"foo": substructNoValidation{},
98+
"bar": substructNoValidation{},
9999
},
100100
// StructPointerSlice []noValidationSub
101101
// InterfaceSlice []testInterface
102102
}
103103
s.InlinedStruct.Integer = 1000
104104
s.InlinedStruct.String = []string{"first", "second"}
105-
s.I_String = "substring"
106-
s.I_Int = 987654
105+
s.IString = "substring"
106+
s.IInt = 987654
107107
return s
108108
}
109109

110110
func TestValidateNoValidationValues(t *testing.T) {
111-
origin := createNoValidation_values()
112-
test := createNoValidation_values()
113-
empty := struct_noValidation_values{}
111+
origin := createNoValidationValues()
112+
test := createNoValidationValues()
113+
empty := structNoValidationValues{}
114114

115115
assert.Nil(t, validate(test))
116116
assert.Nil(t, validate(&test))
@@ -120,8 +120,8 @@ func TestValidateNoValidationValues(t *testing.T) {
120120
assert.Equal(t, origin, test)
121121
}
122122

123-
type struct_noValidation_pointer struct {
124-
substruct_noValidation
123+
type structNoValidationPointer struct {
124+
substructNoValidation
125125

126126
Boolean bool
127127

@@ -143,12 +143,12 @@ type struct_noValidation_pointer struct {
143143

144144
Date *time.Time
145145

146-
Struct *substruct_noValidation
146+
Struct *substructNoValidation
147147

148148
IntSlice *[]int
149149
IntPointerSlice *[]*int
150-
StructPointerSlice *[]*substruct_noValidation
151-
StructSlice *[]substruct_noValidation
150+
StructPointerSlice *[]*substructNoValidation
151+
StructSlice *[]substructNoValidation
152152
InterfaceSlice *[]testInterface
153153

154154
FloatMap *map[string]float32
@@ -158,7 +158,7 @@ type struct_noValidation_pointer struct {
158158
func TestValidateNoValidationPointers(t *testing.T) {
159159
//origin := createNoValidation_values()
160160
//test := createNoValidation_values()
161-
empty := struct_noValidation_pointer{}
161+
empty := structNoValidationPointer{}
162162

163163
//assert.Nil(t, validate(test))
164164
//assert.Nil(t, validate(&test))

context.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (c *Context) reset() {
6969
// Copy returns a copy of the current context that can be safely used outside the request's scope.
7070
// This have to be used then the context has to be passed to a goroutine.
7171
func (c *Context) Copy() *Context {
72-
var cp Context = *c
72+
var cp = *c
7373
cp.writermem.ResponseWriter = nil
7474
cp.Writer = &cp.writermem
7575
cp.index = abortIndex
@@ -172,7 +172,7 @@ func (c *Context) Get(key string) (value interface{}, exists bool) {
172172
return
173173
}
174174

175-
// Returns the value for the given key if it exists, otherwise it panics.
175+
// MustGet returns the value for the given key if it exists, otherwise it panics.
176176
func (c *Context) MustGet(key string) interface{} {
177177
if value, exists := c.Get(key); exists {
178178
return value
@@ -244,7 +244,7 @@ func (c *Context) PostForm(key string) string {
244244
return value
245245
}
246246

247-
// PostForm returns the specified key from a POST urlencoded form or multipart form
247+
// DefaultPostForm returns the specified key from a POST urlencoded form or multipart form
248248
// when it exists, otherwise it returns the specified defaultValue string.
249249
// See: PostForm() and GetPostForm() for further information.
250250
func (c *Context) DefaultPostForm(key, defaultValue string) string {

context_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,14 @@ func TestContextPostFormMultipart(t *testing.T) {
262262
Bar string `form:"bar"`
263263
BarAsInt int `form:"bar"`
264264
Array []string `form:"array"`
265-
Id string `form:"id"`
265+
ID string `form:"id"`
266266
}
267267
assert.NoError(t, c.Bind(&obj))
268268
assert.Equal(t, obj.Foo, "bar")
269269
assert.Equal(t, obj.Bar, "10")
270270
assert.Equal(t, obj.BarAsInt, 10)
271271
assert.Equal(t, obj.Array, []string{"first", "second"})
272-
assert.Equal(t, obj.Id, "")
272+
assert.Equal(t, obj.ID, "")
273273

274274
value, ok := c.GetQuery("foo")
275275
assert.False(t, ok)

errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (msg *Error) JSON() interface{} {
6666
return json
6767
}
6868

69-
// Implements the json.Marshaller interface
69+
// MarshalJSON implements the json.Marshaller interface
7070
func (msg *Error) MarshalJSON() ([]byte, error) {
7171
return json.Marshal(msg.JSON())
7272
}
@@ -89,7 +89,7 @@ func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
8989
if typ == ErrorTypeAny {
9090
return a
9191
}
92-
var result errorMsgs = nil
92+
var result errorMsgs
9393
for _, msg := range a {
9494
if msg.IsType(typ) {
9595
result = append(result, msg)

examples/realtime-advanced/stats.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ var savedStats map[string]uint64
1616

1717
func statsWorker() {
1818
c := time.Tick(1 * time.Second)
19-
var lastMallocs uint64 = 0
20-
var lastFrees uint64 = 0
21-
for _ = range c {
19+
var lastMallocs uint64
20+
var lastFrees uint64
21+
for range c {
2222
var stats runtime.MemStats
2323
runtime.ReadMemStats(&stats)
2424

gin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/gin-gonic/gin/render"
1515
)
1616

17-
// Framework's version
17+
// Version is Framework's version
1818
const Version = "v1.0rc2"
1919

2020
var default404Body = []byte("404 page not found")
@@ -147,19 +147,19 @@ func (engine *Engine) SetHTMLTemplate(templ *template.Template) {
147147
engine.HTMLRender = render.HTMLProduction{Template: templ}
148148
}
149149

150-
// Adds handlers for NoRoute. It return a 404 code by default.
150+
// NoRoute adds handlers for NoRoute. It return a 404 code by default.
151151
func (engine *Engine) NoRoute(handlers ...HandlerFunc) {
152152
engine.noRoute = handlers
153153
engine.rebuild404Handlers()
154154
}
155155

156-
// Sets the handlers called when... TODO
156+
// NoMethod sets the handlers called when... TODO
157157
func (engine *Engine) NoMethod(handlers ...HandlerFunc) {
158158
engine.noMethod = handlers
159159
engine.rebuild405Handlers()
160160
}
161161

162-
// Attachs a global middleware to the router. ie. the middleware attached though Use() will be
162+
// Use attachs a global middleware to the router. ie. the middleware attached though Use() will be
163163
// included in the handlers chain for every single request. Even 404, 405, static files...
164164
// For example, this is the right place for a logger or error management middleware.
165165
func (engine *Engine) Use(middleware ...HandlerFunc) IRoutes {

ginS/gins.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ func SetHTMLTemplate(templ *template.Template) {
3434
engine().SetHTMLTemplate(templ)
3535
}
3636

37-
// Adds handlers for NoRoute. It return a 404 code by default.
37+
// NoRoute adds handlers for NoRoute. It return a 404 code by default.
3838
func NoRoute(handlers ...HandlerFunc) {
3939
engine().NoRoute(handlers...)
4040
}
4141

42-
// Sets the handlers called when... TODO
42+
// NoMethod sets the handlers called when... TODO
4343
func NoMethod(handlers ...HandlerFunc) {
4444
engine().NoMethod(handlers...)
4545
}
4646

47-
// Creates a new router group. You should add all the routes that have common middlwares or the same path prefix.
47+
// Group creates a new router group. You should add all the routes that have common middlwares or the same path prefix.
4848
// For example, all the routes that use a common middlware for authorization could be grouped.
4949
func Group(relativePath string, handlers ...HandlerFunc) *RouterGroup {
5050
return engine().Group(relativePath, handlers...)
@@ -111,28 +111,28 @@ func StaticFS(relativePath string, fs http.FileSystem) IRoutes {
111111
return engine().StaticFS(relativePath, fs)
112112
}
113113

114-
// Attachs a global middleware to the router. ie. the middlewares attached though Use() will be
114+
// Use attachs a global middleware to the router. ie. the middlewares attached though Use() will be
115115
// included in the handlers chain for every single request. Even 404, 405, static files...
116116
// For example, this is the right place for a logger or error management middleware.
117117
func Use(middlewares ...HandlerFunc) IRoutes {
118118
return engine().Use(middlewares...)
119119
}
120120

121-
// The router is attached to a http.Server and starts listening and serving HTTP requests.
121+
// Run : The router is attached to a http.Server and starts listening and serving HTTP requests.
122122
// It is a shortcut for http.ListenAndServe(addr, router)
123123
// Note: this method will block the calling goroutine undefinitelly unless an error happens.
124124
func Run(addr ...string) (err error) {
125125
return engine().Run(addr...)
126126
}
127127

128-
// The router is attached to a http.Server and starts listening and serving HTTPS requests.
128+
// RunTLS : The router is attached to a http.Server and starts listening and serving HTTPS requests.
129129
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
130130
// Note: this method will block the calling goroutine undefinitelly unless an error happens.
131131
func RunTLS(addr string, certFile string, keyFile string) (err error) {
132132
return engine().RunTLS(addr, certFile, keyFile)
133133
}
134134

135-
// The router is attached to a http.Server and starts listening and serving HTTP requests
135+
// RunUnix : The router is attached to a http.Server and starts listening and serving HTTP requests
136136
// through the specified unix socket (ie. a file)
137137
// Note: this method will block the calling goroutine undefinitelly unless an error happens.
138138
func RunUnix(file string) (err error) {

gin_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ func compareFunc(t *testing.T, a, b interface{}) {
201201

202202
func TestListOfRoutes(t *testing.T) {
203203
router := New()
204-
router.GET("/favicon.ico", handler_test1)
205-
router.GET("/", handler_test1)
204+
router.GET("/favicon.ico", handlerTest1)
205+
router.GET("/", handlerTest1)
206206
group := router.Group("/users")
207207
{
208-
group.GET("/", handler_test2)
209-
group.GET("/:id", handler_test1)
210-
group.POST("/:id", handler_test2)
208+
group.GET("/", handlerTest2)
209+
group.GET("/:id", handlerTest1)
210+
group.POST("/:id", handlerTest2)
211211
}
212212
router.Static("/static", ".")
213213

@@ -251,5 +251,5 @@ func assertRoutePresent(t *testing.T, gotRoutes RoutesInfo, wantRoute RouteInfo)
251251
t.Errorf("route not found: %v", wantRoute)
252252
}
253253

254-
func handler_test1(c *Context) {}
255-
func handler_test2(c *Context) {}
254+
func handlerTest1(c *Context) {}
255+
func handlerTest2(c *Context) {}

0 commit comments

Comments
 (0)