Before installing make sure you have the required dependencies installed:
- Guide to Setting a Go Developer Environment
- Go version
- GCC, or equivalent C compiler for mattn/go-sqlite3.
- [OPTIONAL] node and npm for the asset pipeline built upon webpack.
These instructions can also be used for upgrading to a newer version of Buffalo.
$ go get -u -v github.com/gobuffalo/buffalo/...
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/github.com/$USER/ $ # Make sure $GOPATH/bin is in your $PATH, then: $ 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.9.4 --> go get -u golang.org/x/tools/cmd/goimports --> go get -u github.com/golang/dep/cmd/dep --> go get -u github.com/motemen/gore --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/README.md --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/actions/actions_test.go --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/actions/app.go --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/actions/home.go --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/actions/home_test.go --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/actions/render.go --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/.codeclimate.yml --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/.gitignore --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/grifts/init.go --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/locales/all.en-us.yaml --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/main.go --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/templates/_flash.html --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/templates/application.html --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/templates/index.html --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/.buffalo.dev.yml --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/assets/images/logo.svg --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/assets/css/application.scss --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/assets/js/application.js --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/.babelrc --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/public/assets/.gitignore --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/webpack.config.js --> yarn init --no-progress -y --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/models/models.go --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/models/models_test.go --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/grifts/db.go --> go get github.com/markbates/pop/... --> database.yml --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/Dockerfile --> /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/.dockerignore --> go get -t ./... --> git init --> git add . --> git commit -m Initial Commit Congratulations! Your application, coke, has been successfully built! You can find your new application at: /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke Please read the README.md 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 Creates a new Buffalo application Usage: buffalo new [name] [flags] Flags: --api skip all front-end code and configure for an API server --ci-provider string specify the type of ci file you would like buffalo to generate [none, travis, gitlab-ci] (default "none") --db-type string specify the type of database you want to use [postgres, mysql, sqlite3] (default "postgres") --docker string specify the type of Docker file to generate [none, multi, standard] (default "multi") -f, --force delete and remake if the app already exists -h, --help help for new --skip-pop skips adding pop/soda to your app --skip-webpack skips adding Webpack to your app --skip-yarn skip to use npm as the asset package manager -v, --verbose verbosely print out the go get/install commands --with-dep adds github.com/golang/dep to your app
Note: by default, Buffalo generates a database.yml targeted for PostgreSQL. If you wish to change this behavior, you can pass in a
--db-type flag into the
$ buffalo new coke --db-type sqlite3
If your app doesn't need a database, or if you want to handle it by yourself, you can use the
$ buffalo new coke --skip-pop
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
dev command will watch your
.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!
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 0.9.4 --> 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
See Building for more options on the