2017-10-10 84 views
2

我已經創建了Revel測試套件,我使用Assertf檢查錯誤。Golang Revel Assertf導致恐慌

t.Assertf(err == nil, "error occurred: %v", err) 

它在我的Windows和Mac OSX中沒有任何問題。但在我的遠程服務器Ubuntu 16.04中,每當聲明錯誤時,我都會收到類似這樣的錯誤消息。

server.go:2753: http: panic serving [::1]:44626: open /go/src/runtime/debug/stack.go: no such file or directory 

goroutine 74 [running]: 
net/http.(*conn).serve.func1(0xc4204a7f40) 
    /usr/local/go/src/net/http/server.go:1721 +0xd0 
panic(0xa04ba0, 0xc4204c2f60) 
    /usr/local/go/src/runtime/panic.go:489 +0x2cf 
github.com/revel/revel.MustReadLines(0xc420198a4c, 0x1e, 0x1, 0xc4204d2a80, 0x3e) 
    /go/src/github.com/revel/revel/util.go:56 +0x168 
github.com/revel/revel.NewErrorFromPanic(0xa04ba0, 0xc4204c2f00, 0x0) 
    /go/src/github.com/revel/revel/errors.go:63 +0x25b 
github.com/revel/revel.handleInvocationPanic(0xc42024e0c0, 0xa04ba0, 0xc4204c2f00) 
    /go/src/github.com/revel/revel/panic.go:25 +0x4d 
github.com/revel/revel.PanicFilter.func1(0xc42024e0c0) 
    /go/src/github.com/revel/revel/panic.go:16 +0x5c 
panic(0xa04ba0, 0xc4204c2f00) 
    /usr/local/go/src/runtime/panic.go:489 +0x2cf 
github.com/revel/revel.InterceptorFilter.func1(0xc42024e0c0) 
    /go/src/github.com/revel/revel/intercept.go:97 +0x7d 
panic(0xa04ba0, 0xc4204c2f00) 
    /usr/local/go/src/runtime/panic.go:489 +0x2cf 
github.com/revel/revel.MustReadLines(0xc42018605a, 0x1e, 0x1, 0xc420278d10, 0xad) 
    /go/src/github.com/revel/revel/util.go:56 +0x168 
github.com/revel/revel.NewErrorFromPanic(0x9feea0, 0xc4204d8aa0, 0xc4204d8aa0) 
    /go/src/github.com/revel/revel/errors.go:63 +0x25b 
github.com/revel/modules/testrunner/app/controllers.TestRunner.Run.func1.1(0xaa9ba0, 0xc4204c2a80, 0x16, 0xc4204d284c, 0x15, 0xc4204d2862, 0x14, 0xc4203fac78) 
    /go/src/github.com/revel/modules/testrunner/app/controllers/testrunner.go:113 +0x70 
panic(0x9feea0, 0xc4204d8aa0) 
    /usr/local/go/src/runtime/panic.go:489 +0x2cf 
github.com/revel/revel/testing.(*TestSuite).Assertf(0xc4204c2a80, 0xc4203fa600, 0xac7700, 0x16, 0xc4203fa620, 0x1, 0x1) 
    /go/src/github.com/revel/revel/testing/testsuite.go:313 +0x87 
madvrstudio/bnkjigsaw/tests.(*ReceiptValidationTest).TestValidateAppStore(0xc4204c2a80) 
+0

https://github.com/revel/revel/issues/1266 –

回答

1

Assert會觸發恐慌,並且panic過濾器失敗,因爲它無法找到導致錯誤的go代碼的源文件。如果你已經從部署中刪除了源文件,這可能會導致(恕我直言,它實際上不應該),但看着它正在試圖加載堆棧說有錯誤的文件的代碼。

0

這是由於一個錯誤的狂歡 - https://github.com/revel/revel/issues/1287

的問題是,你的服務器有GOPATH設置等於/go,陶醉錯誤地標識的堆棧跟蹤(/usr/local/go/src/runtime/debug/stack.go:24)的第一幀作爲GOPATH因爲是它包含/go/src。您可以通過在任意位置的路徑中手動設置/維護不包含/go的服務器上的其他GOPATH來解決此問題。這也是與官方碼頭集裝箱的問題去找到在https://hub.docker.com/_/golang/