I have created /app/models/todo-item.go file that looks like this:
package models
import (
"github.com/revel/revel"
)
type TodoItem struct {
Id int64 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
}
func (b *TodoItem) Validate(v *revel.Validation) {
v.Check(b.Name,
revel.ValidRequired(),
revel.ValidMaxSize(25))
}
In src/RevelApp/app/controllers/init.go, I have this (PS, I am using GorpController to interact with MySQL):
func defineTodoItemTable(dbm *gorp.DbMap){
// set "id" as primary key and autoincrement
t := dbm.AddTable(models.TodoItem{}).SetKeys(true, "id")
t.ColMap("name").SetMaxSize(25)
}
I am getting an error : The Go code src/RevelApp/app/controllers/init.go does not compile: undefined: models
I have tried importing ."RevelApp/app/models" then doing away with models in models.TodoItem{} (as describer here: Revel with Gorm "undefined: Page") and I get the error : App failed to start up revel/harness: app timed out.
That link is the only one I could find related to this issue. Am I missing something?
EDIT: $GOPATH:
/home/me/Source/go
models location:
/home/me/Source/go/src/RevelApp/app/models
How I am importing models package:
import (
."RevelApp/app/models"
"github.com/revel/revel"
"github.com/coopernurse/gorp"
"database/sql"
_ "github.com/go-sql-driver/mysql"
"fmt"
"strings"
)