gin-swagger icon indicating copy to clipboard operation
gin-swagger copied to clipboard

WARNING: DATA RACE

Open Wp-Otto opened this issue 5 years ago • 2 comments

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/[email protected]/swagger.go:63 +0x169 github.com/gin-gonic/gin.(*Context).Next() /var/www/go-works/pkg/mod/github.com/gin-gonic/[email protected]/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/[email protected]/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/[email protected]/context.go:147 +0xa6 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest() /var/www/go-works/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:403 +0xa45 github.com/gin-gonic/gin.(*Engine).ServeHTTP() /var/www/go-works/pkg/mod/github.com/gin-gonic/[email protected]/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/[email protected]/swagger.go:63 +0x169 github.com/gin-gonic/gin.(*Context).Next() /var/www/go-works/pkg/mod/github.com/gin-gonic/[email protected]/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/[email protected]/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/[email protected]/context.go:147 +0xa6 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest() /var/www/go-works/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:403 +0xa45 github.com/gin-gonic/gin.(*Engine).ServeHTTP() /var/www/go-works/pkg/mod/github.com/gin-gonic/[email protected]/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

Wp-Otto avatar Dec 16 '19 09:12 Wp-Otto

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/[email protected]/swagger.go:63 +0x169

christopher-wong avatar May 08 '20 01:05 christopher-wong

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

ymmemo avatar Jul 22 '21 01:07 ymmemo