Reputation: 1035
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?
Upvotes: 2
Views: 679
Reputation: 13
That works for me. Imports:
import (
"github.com/melkor217/myapp/app/models/mongodb"
"github.com/revel/config"
"github.com/revel/revel"
"log"
)
Load config:
Config, err := config.LoadContext("app.conf", revel.ConfPaths)
Upvotes: 0
Reputation: 135
Comment this lines:
//Config, err := revel.LoadConfig("app.conf")
//if err != nil || Config == nil {
// log.Fatalf("%+v",err)
//}
Upvotes: 1
Reputation: 414
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 := ""
Upvotes: 0