linux下安裝beego(linux(centos/ubuntu) install beego)
阿新 • • 發佈:2018-11-22
1、下載安裝:
$ go get github.com/astaxie/beego
$ go get github.com/beego/bee
2、將 $GOPATH/bin 加入到你的 $PATH 變數中。
3、檢測安裝:
$ bee new hello
$ cd hello
$ bee run hello
一旦程式開始執行,您就可以在瀏覽器中開啟 http://localhost:8080/ 進行訪問。
package main
import (
"github.com/astaxie/beego")
type MainController struct {
beego.Controller}
func (this *MainController) Get() {
this.Ctx.WriteString("hello world")}
func main() {
beego.Router("/", &MainController{})
beego.Run()}
$ go build -o hello hello.go
$ ./hello
瀏覽器輸入: http://127.0.0.1:8080
顯示: “hello world”。