官方文档 https://gobuffalo.io

安装

安装要求

Before installing make sure you have the required dependencies installed:

Frontend Requirements#

The following requirements are optional. You don’t need them if you want to build an API or if you prefer to build your app in an old-fashioned way.

Database Specific Requirements#

Again, if you don’t need a database, you won’t need these.

使用下面的命令安装cli及相关工具

go install  github.com/gobuffalo/cli/cmd/buffalo@latest
go install  github.com/gobuffalo/buffalo-pop/v3@latest

如果需要sqlite支持,请使用下面的命令

go install -tags sqlite github.com/gobuffalo/cli/cmd/buffalo@latest
go install -tags sqlite github.com/gobuffalo/buffalo-pop/v3@latest

因为国内的原因,npm等组件可能因为某些原因下载不了,可以通过下面的内容设置mirror

npm config set registry https://registry.npmmirror.com

yarn工具设置代理

yarn config set https-proxy http://host:port
yarn config set proxy http://host:port

创建项目及运行

通过下面命令创建项目

buffalo new tinyApp --db-type sqlite3

然后切换到tiny_app目录,运行

buffalo dev

运行效果如下

image-20230130130031874