As of December 1st, 2019 Buffalo, and all related packages, require Go Modules and the use of the GOPATH is no longer supported.

Please see this blog post for more information

Flash Messages

What are Flash Messages?

Flash messages are a means of communicating messages to the end user from inside of an application. These messages might be errors, warnings, or success types of messages.

Some examples of flash messages are:

  • "You have been successfully logged out."
  • "Your widget could not be updated."
  • "There was a problem accessing your account."

Being able to set these messages in a Buffalo handler and then pass them down to views is incredibly helpful.

Setting Flash Messages

Creating flash messages can easily be done by using the c.Flash() function provided on the buffalo.Context.

func WidgetsCreate(c buffalo.Context) error {
  // do some work
  c.Flash().Add("success", "Widget was successfully created!")
  // do more work and return

The names of the "keys", in this example, "success", are left up to your application to use as is appropriate. There are no "special" or "pre-defined" keys.

Accessing Flash Messages in Templates

This document only applies when using
Please see for more details on the underlying templating package.

Looping Over all Flash Messages

<div class="row">
  <div class="col-md-12">
    <%= for (k, messages) in flash { %>
      <%= for (msg) in messages { %>
        <div class="alert alert-<%= k %>" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
          <%= msg %>
      <% } %>
    <% } %>

Looping Over a Specific Flash Message Key

<div class="row">
  <div class="col-md-12">
    <%= for (message) in flash["success"] { %>
      <div class="alert alert-success" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×
        <%= message %>
    <% } %>