swaggo / gin-swagger

gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
MIT License
3.75k stars 269 forks source link

WARNING: DATA RACE #94

Open Wp-Otto opened 4 years ago

Wp-Otto commented 4 years ago
go func() {
    if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
        log.Fatalf("HTTP server listen: %s\n", err)
    }
}()

================== WARNING: DATA RACE Write at 0x00c000217400 by goroutine 61: github.com/swaggo/gin-swagger.CustomWrapHandler.func1() /var/www/go-works/pkg/mod/github.com/swaggo/gin-swagger@v1.2.0/swagger.go:63 +0x169 github.com/gin-gonic/gin.(Context).Next() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/context.go:147 +0xa6 go-tgbus-api/app/middleware/exception.SetUp.func1() /var/www/go-modules/go-tgbus-api/app/middleware/exception/exception.go:57 +0x7f github.com/gin-gonic/gin.(Context).Next() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/context.go:147 +0xa6 go-tgbus-api/app/middleware/logger.SetUp.func1() /var/www/go-modules/go-tgbus-api/app/middleware/logger/logger.go:45 +0x23a github.com/gin-gonic/gin.(Context).Next() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/context.go:147 +0xa6 github.com/gin-gonic/gin.(Engine).handleHTTPRequest() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/gin.go:403 +0xa45 github.com/gin-gonic/gin.(Engine).ServeHTTP() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/gin.go:364 +0x2f4 net/http.serverHandler.ServeHTTP() /usr/local/go/src/net/http/server.go:2802 +0xce net/http.(conn).serve() /usr/local/go/src/net/http/server.go:1890 +0x837

Previous write at 0x00c000217400 by goroutine 361: github.com/swaggo/gin-swagger.CustomWrapHandler.func1() /var/www/go-works/pkg/mod/github.com/swaggo/gin-swagger@v1.2.0/swagger.go:63 +0x169 github.com/gin-gonic/gin.(Context).Next() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/context.go:147 +0xa6 go-tgbus-api/app/middleware/exception.SetUp.func1() /var/www/go-modules/go-tgbus-api/app/middleware/exception/exception.go:57 +0x7f github.com/gin-gonic/gin.(Context).Next() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/context.go:147 +0xa6 go-tgbus-api/app/middleware/logger.SetUp.func1() /var/www/go-modules/go-tgbus-api/app/middleware/logger/logger.go:45 +0x23a github.com/gin-gonic/gin.(Context).Next() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/context.go:147 +0xa6 github.com/gin-gonic/gin.(Engine).handleHTTPRequest() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/gin.go:403 +0xa45 github.com/gin-gonic/gin.(Engine).ServeHTTP() /var/www/go-works/pkg/mod/github.com/gin-gonic/gin@v1.5.0/gin.go:364 +0x2f4 net/http.serverHandler.ServeHTTP() /usr/local/go/src/net/http/server.go:2802 +0xce net/http.(conn).serve() /usr/local/go/src/net/http/server.go:1890 +0x837

Goroutine 61 (running) created at: net/http.(Server).Serve() /usr/local/go/src/net/http/server.go:2927 +0x5be net/http.(Server).ListenAndServe() /usr/local/go/src/net/http/server.go:2825 +0x102 main.main.func1() /var/www/go-modules/go-tgbus-api/main.go:60 +0x3c

Goroutine 361 (running) created at: net/http.(Server).Serve() /usr/local/go/src/net/http/server.go:2927 +0x5be net/http.(Server).ListenAndServe() /usr/local/go/src/net/http/server.go:2825 +0x102 main.main.func1() /var/www/go-modules/go-tgbus-api/main.go:60 +0x3c

christopher-wong commented 4 years ago

I'm running into this issue on the latest 1.2.0 release.

WARNING: DATA RACE
Write at 0x00c000074500 by goroutine 45:
github.com/swaggo/gin-swagger.CustomWrapHandler.func1()
/go/pkg/mod/github.com/swaggo/gin-swagger@v1.2.0/swagger.go:63 +0x169
ymmemo commented 3 years ago

same problem. Is there a better way to avoid this?