Go代码无法编译:undefined: revel.EmptyPlugin

huangapple go评论93阅读模式
英文:

The Go code does not compile: undefined: revel.EmptyPlugin

问题

我和几个朋友正在使用golang(revel)编写一个服务器,并且在几周前实现了一个数据库。然后突然间一切都停止工作了,go编译器找不到我的导入文件。这包括EmptyPlugin和RegisterPlugin。

我们都是新手,所以这可能是一个相当简单的修复。我已经检查了我的github.com/robfig/revel文件夹,没有叫做EmptyPlugin的文件。但这可能是我误解了:P。

通过注释掉revel.EmptyPlugin和revel.RegisterPlugin(DbPlugin{})这两行,一切都正常工作。

package controllers

import (
	"database/sql"
	"fmt"
	_ "github.com/bmizerany/pq"
	"github.com/robfig/revel"
	"log"
	"time"
	//"strconv"
)

type DbPlugin struct {
	revel.EmptyPlugin
}



func init() {
	revel.RegisterPlugin(DbPlugin{})
}


var db *sql.DB 
var err error
英文:

Me and a few friends are writing a server using golang (revel) and had a database implemented just a few weeks ago. Then suddenly everything just stopped working and the go compiler can't find my import files. That includes EmptyPlugin as well as RegisterPlugin.

We are all pretty new so this is probably a pretty simple fix. I have checked my github.com/robfig/revel folder, and there is no file called EmptyPlugin. But that is probably a misunderstanding from my side :P.

By commenting the lines revel.EmptyPlugin and revel.RegisterPlugin(DbPlugin{}) everything works as it should.

package controllers

import (
	"database/sql"
	"fmt"
	_ "github.com/bmizerany/pq"
	"github.com/robfig/revel"
	"log"
	"time"
	//"strconv"
)

type DbPlugin struct {
	revel.EmptyPlugin
}



func init() {
	revel.RegisterPlugin(DbPlugin{})
}


var db *sql.DB 
var err error

答案1

得分: 2

您似乎正在使用最新和最近更新的Revel版本进行编译:https://github.com/robfig/revel。

然而,看起来您的代码是针对这个较旧版本的Revel编写的:https://github.com/robfig/revel/tree/dev。

请将您的代码更新到最新版本的Revel。

英文:

You appear to compiling using the latest and recently updated version of Revel: https://github.com/robfig/revel.

However, it appears that your code was written for this older version of Revel: https://github.com/robfig/revel/tree/dev.

Update your code to the latest version of Revel.

huangapple
  • 本文由 发表于 2013年6月14日 21:21:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/17109504.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定