Skip to content

Commit 268e788

Browse files
committed
chore: fix lint
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 95ad899 commit 268e788

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,29 @@ import "github.com/gin-contrib/static"
2727

2828
See the [example](example)
2929

30-
[embedmd]:# (_example/simple/example.go go)
3130
```go
3231
package main
3332

3433
import (
35-
"github.com/gin-contrib/static"
36-
"github.com/gin-gonic/gin"
34+
"github.com/gin-contrib/static"
35+
"github.com/gin-gonic/gin"
3736
)
3837

3938
func main() {
40-
r := gin.Default()
41-
42-
// if Allow DirectoryIndex
43-
//r.Use(static.Serve("/", static.LocalFile("/tmp", true)))
44-
// set prefix
45-
//r.Use(static.Serve("/static", static.LocalFile("/tmp", true)))
46-
47-
r.Use(static.Serve("/", static.LocalFile("/tmp", false)))
48-
r.GET("/ping", func(c *gin.Context) {
49-
c.String(200, "test")
50-
})
51-
// Listen and Server in 0.0.0.0:8080
52-
r.Run(":8080")
39+
r := gin.Default()
40+
41+
// if Allow DirectoryIndex
42+
//r.Use(static.Serve("/", static.LocalFile("/tmp", true)))
43+
// set prefix
44+
//r.Use(static.Serve("/static", static.LocalFile("/tmp", true)))
45+
46+
r.Use(static.Serve("/", static.LocalFile("/tmp", false)))
47+
r.GET("/ping", func(c *gin.Context) {
48+
c.String(200, "test")
49+
})
50+
// Listen and Server in 0.0.0.0:8080
51+
if err := r.Run(":8080"); err != nil {
52+
log.Fatal(err)
53+
}
5354
}
5455
```

_example/bindata/example.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"log"
45
"net/http"
56
"strings"
67

@@ -18,7 +19,6 @@ func (b *binaryFileSystem) Open(name string) (http.File, error) {
1819
}
1920

2021
func (b *binaryFileSystem) Exists(prefix string, filepath string) bool {
21-
2222
if p := strings.TrimPrefix(filepath, prefix); len(p) < len(filepath) {
2323
if _, err := b.fs.Open(p); err != nil {
2424
return false
@@ -47,5 +47,7 @@ func main() {
4747
c.String(200, "test")
4848
})
4949
// Listen and Server in 0.0.0.0:8080
50-
r.Run(":8080")
50+
if err := r.Run(":8080"); err != nil {
51+
log.Fatal(err)
52+
}
5153
}

_example/simple/example.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"log"
5+
46
"github.com/gin-contrib/static"
57
"github.com/gin-gonic/gin"
68
)
@@ -9,14 +11,16 @@ func main() {
911
r := gin.Default()
1012

1113
// if Allow DirectoryIndex
12-
//r.Use(static.Serve("/", static.LocalFile("/tmp", true)))
14+
// r.Use(static.Serve("/", static.LocalFile("/tmp", true)))
1315
// set prefix
14-
//r.Use(static.Serve("/static", static.LocalFile("/tmp", true)))
16+
// r.Use(static.Serve("/static", static.LocalFile("/tmp", true)))
1517

1618
r.Use(static.Serve("/", static.LocalFile("/tmp", false)))
1719
r.GET("/ping", func(c *gin.Context) {
1820
c.String(200, "test")
1921
})
2022
// Listen and Server in 0.0.0.0:8080
21-
r.Run(":8080")
23+
if err := r.Run(":8080"); err != nil {
24+
log.Fatal(err)
25+
}
2226
}

static_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestEmptyDirectory(t *testing.T) {
2828
t.Error(err)
2929
}
3030
defer os.Remove(f.Name())
31-
f.WriteString("Gin Web Framework")
31+
_, _ = f.WriteString("Gin Web Framework")
3232
f.Close()
3333

3434
dir, filename := filepath.Split(f.Name())
@@ -94,7 +94,7 @@ func TestIndex(t *testing.T) {
9494
t.Error(err)
9595
}
9696
defer os.Remove(f.Name())
97-
f.WriteString("index")
97+
_, _ = f.WriteString("index")
9898
f.Close()
9999

100100
dir, filename := filepath.Split(f.Name())
@@ -118,7 +118,7 @@ func TestListIndex(t *testing.T) {
118118
t.Error(err)
119119
}
120120
defer os.Remove(f.Name())
121-
f.WriteString("Gin Web Framework")
121+
_, _ = f.WriteString("Gin Web Framework")
122122
f.Close()
123123

124124
dir, filename := filepath.Split(f.Name())

0 commit comments

Comments
 (0)