linux下安装beego(linux(centos/ubuntu) install beego)

版权声明:标为原创文章的,转载请注明出处。 https://blog.csdn.net/guestcode/article/details/45249485


1、下载安装:

$ go get github.com/astaxie/beego

$ go get github.com/beego/bee


2、将 $GOPATH/bin 加入到你的 $PATH 变量中。


3、检测安装:

$ cd $GOPATH/src
$ bee new hello
$ cd hello
$ bee run hello


一旦程序开始运行,您就可以在浏览器中打开 http://localhost:8080/ 进行访问。


4、简单示例:
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()}


把上面的代码保存为 hello.go,然后通过命令行进行编译并执行:
$ go build -o hello hello.go

$ ./hello


浏览器输入: http://127.0.0.1:8080

显示: “hello world”。



猜你喜欢

转载自blog.csdn.net/guestcode/article/details/45249485