在代码中声明但未调用的函数时继续恐慌
Go panics on when having functions declared in code but not called
上下文:
https://github.com/fusspawn/tserver/blob/master/app/controllers/gorp.go
作为尝试设置 gorm 的一部分,我尝试转换标准 revel/gorp 示例。
不过。即使定义了 Begin()、Commit()、Rollback() 方法也足以导致恐慌。
TRACE 2015/09/06 17:37:47 harness.go:126: Rebuild
INFO 2015/09/06 17:37:47 build.go:172: Cleaning dir tmp
INFO 2015/09/06 17:37:47 build.go:172: Cleaning dir routes
INFO 2015/09/06 17:37:47 build.go:172: Cleaning dir tmp
INFO 2015/09/06 17:37:47 build.go:172: Cleaning dir routes
TRACE 2015/09/06 17:37:47 build.go:151: Exec: [/usr/bin/git --git- dir=/home/fusspawn/go/src/github.com/fusspawn/tserver/.git describe --always -- dirty]
TRACE 2015/09/06 17:37:47 build.go:94: Exec: [/usr/bin/go build -ldflags -X github.com/fusspawn/tserver/app.APP_VERSION "git-2588ef1" -tags -o /ho
me/fusspawn/go/bin/revel.d/github.com/fusspawn/tserver/tserver github.com/fusspawn/tserver/app/tmp]
TRACE 2015/09/06 17:39:14 app.go:56: Exec app: /home/fusspawn/go/bin/revel.d/github.com/fusspawn/tserver/tserver [/home/fusspawn/go/bin/revel.d/git
hub.com/fusspawn/tserver/tserver -port=46276 - importPath=github.com/fusspawn/tserver -runMode=dev]
INFO 2015/09/06 17:39:14 revel.go:329: Loaded module static
INFO 2015/09/06 17:39:14 revel.go:329: Loaded module testrunner
INFO 2015/09/06 17:39:14 revel.go:206: Initialized Revel v0.12.0 (2015-03-25) for >= go1.3
INFO 2015/09/06 17:39:14 main.go:30: Running revel server
TRACE 2015/09/06 17:39:14 controller.go:402: Registered controller: App
panic: reflect: call of reflect.Value.Type on zero Value
goroutine 1 [running]:
runtime.panic(0x88cec0, 0xc21011b7a0)
/usr/lib/go/src/pkg/runtime/panic.c:266 +0xb6
reflect.Value.Type(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/lib/go/src/pkg/reflect/value.go:1698 +0x79
github.com/revel/revel.findControllers(0x7f365698bea8, 0x9186e0, 0x0, 0x0, 0x0)
/home/fusspawn/go/src/github.com/revel/revel/controller.go:321 +0x25a
github.com/revel/revel.RegisterController(0x9172a0, 0x0, 0xc2100c4bf0, 0x2, 0x2)
/home/fusspawn/go/src/github.com/revel/revel/controller.go:400 +0x1f3
main.main()
/home/fusspawn/go/src/github.com/fusspawn/tserver/app/tmp/main.go:150 +0x141b
TRACE 2015/09/06 17:39:14 controller.go:402: Registered controller: GormController
TRACE 2015/09/06 17:39:14 controller.go:402: Registered controller: Static
TRACE 2015/09/06 17:39:14 controller.go:402: Registered controller: TestRunner
注释掉方法定义将停止恐慌。我似乎无法理解如何不调用这些方法(注意 revel.InterceptMethod 调用被注释掉)会导致恐慌发生:/
根据 Revel 文档,系统通过 scanning your source directory 寻找处于调试模式的控制器,以查找任何执行 *Revel.Controller
匿名嵌入的内容。您看到的错误是由于 Revel 在此控制器扫描初始化期间进行动态反射并搞砸了。所以现在的问题是:为什么扫描控制器时遇到问题?
您的代码似乎试图扩展 EventStream, which the Revel debug controller-discovery code will try to read as a Controller. However, the code as it stands is currently violating expectations of the framework by embedding a *GormController
instead of a GormController
; see the last part of the Controllers documentation 中的控制器。
我认为控制器发现逻辑因此而令人窒息。修复 EventStream
结构定义。
如果这确实为您解决了问题,您可能应该向 Revel 人员发送错误报告,因为您收到的错误消息非常糟糕并且是非本地的,因为它没有提到失败时尝试注册为控制器的事物的名称。
上下文: https://github.com/fusspawn/tserver/blob/master/app/controllers/gorp.go
作为尝试设置 gorm 的一部分,我尝试转换标准 revel/gorp 示例。
不过。即使定义了 Begin()、Commit()、Rollback() 方法也足以导致恐慌。
TRACE 2015/09/06 17:37:47 harness.go:126: Rebuild
INFO 2015/09/06 17:37:47 build.go:172: Cleaning dir tmp
INFO 2015/09/06 17:37:47 build.go:172: Cleaning dir routes
INFO 2015/09/06 17:37:47 build.go:172: Cleaning dir tmp
INFO 2015/09/06 17:37:47 build.go:172: Cleaning dir routes
TRACE 2015/09/06 17:37:47 build.go:151: Exec: [/usr/bin/git --git- dir=/home/fusspawn/go/src/github.com/fusspawn/tserver/.git describe --always -- dirty]
TRACE 2015/09/06 17:37:47 build.go:94: Exec: [/usr/bin/go build -ldflags -X github.com/fusspawn/tserver/app.APP_VERSION "git-2588ef1" -tags -o /ho
me/fusspawn/go/bin/revel.d/github.com/fusspawn/tserver/tserver github.com/fusspawn/tserver/app/tmp]
TRACE 2015/09/06 17:39:14 app.go:56: Exec app: /home/fusspawn/go/bin/revel.d/github.com/fusspawn/tserver/tserver [/home/fusspawn/go/bin/revel.d/git
hub.com/fusspawn/tserver/tserver -port=46276 - importPath=github.com/fusspawn/tserver -runMode=dev]
INFO 2015/09/06 17:39:14 revel.go:329: Loaded module static
INFO 2015/09/06 17:39:14 revel.go:329: Loaded module testrunner
INFO 2015/09/06 17:39:14 revel.go:206: Initialized Revel v0.12.0 (2015-03-25) for >= go1.3
INFO 2015/09/06 17:39:14 main.go:30: Running revel server
TRACE 2015/09/06 17:39:14 controller.go:402: Registered controller: App
panic: reflect: call of reflect.Value.Type on zero Value
goroutine 1 [running]:
runtime.panic(0x88cec0, 0xc21011b7a0)
/usr/lib/go/src/pkg/runtime/panic.c:266 +0xb6
reflect.Value.Type(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/lib/go/src/pkg/reflect/value.go:1698 +0x79
github.com/revel/revel.findControllers(0x7f365698bea8, 0x9186e0, 0x0, 0x0, 0x0)
/home/fusspawn/go/src/github.com/revel/revel/controller.go:321 +0x25a
github.com/revel/revel.RegisterController(0x9172a0, 0x0, 0xc2100c4bf0, 0x2, 0x2)
/home/fusspawn/go/src/github.com/revel/revel/controller.go:400 +0x1f3
main.main()
/home/fusspawn/go/src/github.com/fusspawn/tserver/app/tmp/main.go:150 +0x141b
TRACE 2015/09/06 17:39:14 controller.go:402: Registered controller: GormController
TRACE 2015/09/06 17:39:14 controller.go:402: Registered controller: Static
TRACE 2015/09/06 17:39:14 controller.go:402: Registered controller: TestRunner
注释掉方法定义将停止恐慌。我似乎无法理解如何不调用这些方法(注意 revel.InterceptMethod 调用被注释掉)会导致恐慌发生:/
根据 Revel 文档,系统通过 scanning your source directory 寻找处于调试模式的控制器,以查找任何执行 *Revel.Controller
匿名嵌入的内容。您看到的错误是由于 Revel 在此控制器扫描初始化期间进行动态反射并搞砸了。所以现在的问题是:为什么扫描控制器时遇到问题?
您的代码似乎试图扩展 EventStream, which the Revel debug controller-discovery code will try to read as a Controller. However, the code as it stands is currently violating expectations of the framework by embedding a *GormController
instead of a GormController
; see the last part of the Controllers documentation 中的控制器。
我认为控制器发现逻辑因此而令人窒息。修复 EventStream
结构定义。
如果这确实为您解决了问题,您可能应该向 Revel 人员发送错误报告,因为您收到的错误消息非常糟糕并且是非本地的,因为它没有提到失败时尝试注册为控制器的事物的名称。