Skip to content

Commit d361912

Browse files
committed
chore: fix lint
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 111c2d5 commit d361912

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ import "github.com/gin-contrib/static"
2727

2828
See the [example](example)
2929

30+
<<<<<<< HEAD
3031
#### Serve local file
3132

33+
=======
34+
>>>>>>> 268e788 (chore: fix lint)
3235
```go
3336
package main
3437

@@ -83,5 +86,8 @@ func main() {
8386
})
8487
// Listen and Server in 0.0.0.0:8080
8588
r.Run(":8080")
89+
if err := r.Run(":8080"); err != nil {
90+
log.Fatal(err)
91+
}
8692
}
8793
```

_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
}

serve_test.go

Lines changed: 2 additions & 2 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())

0 commit comments

Comments
 (0)