Learn REVEL with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
1
Revel Simple Todo App
// app/controllers/todo.go
package controllers
import (
"github.com/revel/revel"
)
type Todo struct {
ID int
Title string
Completed bool
}
var todos []Todo
type TodoController struct {
*revel.Controller
}
func (c TodoController) Index() revel.Result {
return c.Render(todos)
}
func (c TodoController) Create(title string) revel.Result {
todo := Todo{ID: len(todos)+1, Title: title, Completed: false}
todos = append(todos, todo)
return c.Redirect(TodoController.Index)
}
// app/views/Todo/Index.html
<h1>Todo List</h1>
<ul>
{{range .todos}}
<li>{{.Title}}</li>
{{end}}
</ul>
<form action="/Todo/Create" method="post">
<input type="text" name="title">
<button type="submit">Add Todo</button>
</form>
Demonstrates a simple Revel controller and view for managing Todo items using MVC architecture.