Getting Started


$ go get -u

Generating a New Project

Buffalo aims to make building new web applications in Go as quick and simple as possible, and what could be more simple than a new application generator? Start by going to your $GOPATH and create your new application!

$ cd $GOPATH/src/$USER/
$ buffalo new 

That will generate a whole new Buffalo application that is ready to go. It'll even run go get for you to make sure you have all of the necessary dependencies needed to run your application.

$ buffalo new coke
Buffalo version 0.8.0

--> .../coke/ --> .../coke/actions/actions_test.go --> .../coke/actions/app.go --> .../coke/actions/home.go --> .../coke/actions/home_test.go --> .../coke/actions/render.go --> .../coke/.codeclimate.yml --> .../coke/.gitignore --> .../coke/grifts/routes.go --> .../coke/main.go --> .../coke/templates/application.html --> .../coke/templates/index.html --> .../coke/ --> go get --> go install --> go get --> go install --> go get --> go install --> .../coke/assets/images/logo.svg --> .../coke/assets/css/application.scss --> .../coke/assets/js/application.js --> .../coke/public/assets/.gitignore --> .../coke/webpack.config.js --> npm init -y --> .../coke/models/models.go --> .../coke/models/models_test.go --> go get --> go install --> database.yml --> go get -t ./... --> goimports -w . Congratulations! Your application, coke, has been successfully built!

You can find your new application at: .../coke

Please read the file in your new application for next steps on running your application.

To see a list of available flags for the new command, just check out its help.

$ buffalo help new

Note: by default, Buffalo generates a database.yml targeted for postgres. If you wish to change this behavior, you can pass in a --db-type flag into the new command.

$ buffalo new coke --db-type sqlite3

Running Your Application in Development

Before starting Buffalo for the first time, please head over to the Database docs and read a little bit about setting up your databases.

One of the downsides to Go development is the lack of code "reloading". This means as you change your code you need to manually stop your application, rebuild it, and then restart it. Buffalo finds this is annoying, and wants to make life better for you.

$ buffalo dev

The dev command will watch your .go and .html files and the asset folder by default. It will rebuild and restart your binary for you automatically so you don't have to worry about such things.

Just run the buffalo dev command and go to localhost:3000/ to see all changes live!

Building Your Application

Buffalo features a command, build, that will build a full binary of your application including, but not limited to; assets, migrations, templates, etc... If you buy into the "Buffalo Way" things just work. It's a wonderful experience. :)

$ buffalo build

Buffalo version

--> cleaning up target dir --> running node_modules/.bin/webpack --> packing .../coke/actions/actions-packr.go --> running go build -v -o bin/gobuffalo -ldflags -X main.version=b5dffda -X main.buildTime="2017-03-20T11:05:23-04:00" --> cleaning up build ----> cleaning up buffalo_build_main.go ----> cleaning up a ----> cleaning up a/a.go ----> cleaning up a/database.go ----> cleaning up buffalo_build_main.go ----> cleaning up ...coke/actions/actions-packr.go