doulai6469 2016-10-18 10:22
浏览 80

未定义:在revel应用程序启动时显示revel.LoadConfig

I was following this tutorial on using Go + Revel + MongoDB. But as I starting the application, I got this error:

The Go code api-go/app/init.go does not compile: undefined: revel.LoadConfig

along with other errors as I look in the terminal.

ERROR 2016/10/18 17:15:06 build.go:108: # api-go/app
api-go/app/init.go:41: undefined: revel.LoadConfig
api-go/app/init.go:43: undefined: log in log.Fatalf
api-go/app/init.go:45: undefined: mongodb in mongodb.MaxPool
api-go/app/init.go:45: cannot assign to mongodb.MaxPool
api-go/app/init.go:46: undefined: mongodb in mongodb.PATH
api-go/app/init.go:46: cannot assign to mongodb.PATH
api-go/app/init.go:47: undefined: mongodb in mongodb.DBNAME
api-go/app/init.go:47: cannot assign to mongodb.DBNAME
api-go/app/init.go:48: undefined: mongodb in mongodb.CheckAndInitServiceConnection

I used Mac Sierra. What's wrong with my application?

error on browser

  • 写回答

3条回答 默认 最新

  • dongzhi5386 2016-10-19 07:55
    关注

    As I see your errors I think you should add in your file "init.go" this code

         import ( 
            "log"
            "github.com/revel/revel" 
            “myapp/app/models/mongodb”
          ) 
    

    This just under the first line of your init.go whitch contain "package"

    Next in your code you have to replace:

       revel.LoadConfig("app.conf")
    

    by

       revel.config.LoadContext("app.conf",ConfPaths)
    

    where confPaths is the string path to your conf file. In your case it can be:

        ConfPaths := "conf/"
    

    or

        ConfPaths := ""
    
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮