我和几个 friend 正在使用 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
最佳答案
您似乎使用最新和最近更新的 Revel 版本进行编译:https://github.com/robfig/revel .
但是,您的代码似乎是为 Revel 的旧版本编写的:https://github.com/robfig/revel/tree/dev .
将您的代码更新到最新版本的 Revel。
关于go - Go 代码不编译 : undefined: revel. EmptyPlugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17109504/