What’s New

File Uploads

File uploads in Buffalo are now a first class citizen!

In the buffalo.Context the c.File takes a string, the name of the form file parameter and will return a binding.File that can be used to easily retrieve a file from the from.

func SomeHandler(c buffalo.Context) error {

// ...

f, err := c.File("someFile")

if err != nil {

return errors.WithStack(err)

}

// ...

}

The c.Bind allows form elements to be bound to a struct, but it can also attach uploaded files to the struct. To do this, the type of the struct attribute must be a binding.File type.

type Widget struct {

ID uuid.UUID `json:"id" db:"id"`

CreatedAt time.Time `json:"created_at" db:"created_at"`

UpdatedAt time.Time `json:"updated_at" db:"updated_at"`

Name string `json:"name" db:"name"`

MyFile binding.File `db:"-" form:"someFile"`

}

Once you have access to the file you can do with it as you please, but it is up to you handle where the files live, whether that be on disk or on S3.

Full docs for file uploads, including how to test file uploads, can be found at https://gobuffalo.io/docs/file-uploads

UNIX Socket Support

UNIX Sockets are a common way to do inter-process communication (IPC) on UNIX systems. This means a program **A** can talk to a program **B**, using a file descriptor, just like they do using the TCP stack. Buffalo can now be configured to use unix sockets instead of a TCP port.

This allows you to have an instance of Buffalo running behind a proxy, without having to handle the full TCP stack between Buffalo and the proxy. This way, your app will answer faster!

To bind Buffalo to an UNIX socket, you need to define the ADDR env variable:

ADDR=unix:/tmp/buffalo.sock

You can use the path you want. Here, Buffalo will reply on the /tmp/buffalo.sock socket.

Full docs for UNIX sockets can be found at https://gobuffalo.io/docs/proxy.

Improved Windows Support

A lot of work went into fixing issues on Windows in this release. In addition to all of the bug fixes for Windows, we finally have some automated Windows testing setup at https://ci.appveyor.com/project/markbates/buffalo.

Over time this testing will get more and more extensive. In addition to Buffalo, other projects such as Plush and Packr also now have their tests running on Windows, in addition to the Travis CI tests.

As we work towards a 1.0 release, hopefully this year, making sure we aren’t delivering regressions, and/or broken releases, to Windows users will be a requirement towards that goal.

PreBuilt Binaries

A lot of requests have been made to get pre-built Buffalo binaries. In this release we now them, thanks to the GoReleaser tool.

There are currently 4 binaries that are generated:

Without SQLite Support:

Windows/amd64

Darwin/amd64

Linux/amd64

With SQLite Support:

Darwin/amd64

Due to technical limitations currently only the pre-built binary for Mac contains SQLite support. For more information on the future of SQLite support in Pop/Buffalo, please read this https://github.com/markbates/pop/issues/164

Binaries can be found at:

https://github.com/gobuffalo/buffalo/releases/tag/v0.10.3

Template Error Line Numbers

While a seemingly small feature, this issue has repeatedly been requested in Plush. Plush will now attempt to give a line number when there is an error in your templates.

Now you will get errors such as this: