go環境及bee工具安裝

go環境及bee工具安裝

一、go環境安裝

  • 1.解壓go安裝包:tar -xvf go1.11.1.linux-amd64.tar.gz -C /usr/local/

  • 2.設置go環境變量
    export GOROOT=/usr/local/go
    export GOPATH=/app/apps
    export GOBIN=$GOROOT/bin
    export PATH=$PATH:$GOBIN:$GOPATH/bin
  • 3 go環境驗證
    go version 
    go version go1.11.1 linux/amd64

    二、bee工具安裝

  • 第一種方式 go get github.com/beego/bee 會把編譯好的bee可執行文件放到$GOPATH/bin,所以需要提前設置好PATH環境變量
  • 第二種方式 手動上傳並編譯bee
    • 打開github網頁,克隆並下載bee源碼
    • 上傳bee源碼到/app/apps/src/github.com/beego/
    • cd /app/apps/src/github.com/beego/;gu build
    • 將可執行文件bee 轉移到$GOPATH/bin
    • 執行 bee測試安裝是否成功
  • bee環境驗證

    bee version 
    ______
    | ___ \
    | |_/ /  ___   ___
    | ___ \ / _ \ / _ \
    | |_/ /|  __/|  __/
    \____/  \___| \___| v1.10.0
    
    ?..?€ Beego     : Beego is not installed. Please do consider installing it first: https://github.com/astaxie/beego
    ?..?€ GoVersion : go1.11.1
    ?..?€ GOOS      : linux
    ?..?€ GOARCH    : amd64
    ?..?€ NumCPU    : 4
    ?..?€ GOPATH    : /app/apps
    ?..?€ GOROOT    : /usr/local/go
    ?..?€ Compiler  : gc
    ?..?€ Date      : Wednesday, 5 Dec 2018

    三、新建一個bee工程

    ]# bee new webad 
    ______
    | ___ \
    | |_/ /  ___   ___
    | ___ \ / _ \ / _ \
    | |_/ /|  __/|  __/
    \____/  \___| \___| v1.10.0
    2018/12/05 11:02:27 INFO     ??0001 Creating application...
        create   /app/apps/src/webad/
        create   /app/apps/src/webad/conf/
        create   /app/apps/src/webad/controllers/
        create   /app/apps/src/webad/models/
        create   /app/apps/src/webad/routers/
        create   /app/apps/src/webad/tests/
        create   /app/apps/src/webad/static/
        create   /app/apps/src/webad/static/js/
        create   /app/apps/src/webad/static/css/
        create   /app/apps/src/webad/static/img/
        create   /app/apps/src/webad/views/
        create   /app/apps/src/webad/conf/app.conf
        create   /app/apps/src/webad/controllers/default.go
        create   /app/apps/src/webad/views/index.tpl
        create   /app/apps/src/webad/routers/router.go
        create   /app/apps/src/webad/tests/default_test.go
        create   /app/apps/src/webad/main.go
     2018/12/05 11:02:27 SUCCESS  ??0002 New application successfully created!

四、下載beego並運行beego

  • go get github.com/astaxie/beego或者手動下載上傳(參考bee工具手動安裝)
  • 運行beego
    
    webad]# bee run 
    ______
    | ___ \
    | |_/ /  ___   ___
    | ___ \ / _ \ / _ \
    | |_/ /|  __/|  __/
    \____/  \___| \___| v1.10.0
    2018/12/05 11:10:00 INFO     ??0001 Using 'webad' as 'appname'
    2018/12/05 11:10:00 INFO     ??0002 Initializing watcher...
    github.com/astaxie/beego/config
    github.com/astaxie/beego/utils
    github.com/astaxie/beego/vendor/gopkg.in/yaml.v2
    github.com/astaxie/beego/logs
    github.com/astaxie/beego/session
    github.com/astaxie/beego/grace
    github.com/astaxie/beego/toolbox
    github.com/astaxie/beego/vendor/golang.org/x/crypto/acme
    github.com/astaxie/beego/vendor/golang.org/x/crypto/acme/autocert
    github.com/astaxie/beego/context
    github.com/astaxie/beego/context/param
    github.com/astaxie/beego
    webad/controllers
    webad/routers
    webad
    2018/12/05 11:10:03 SUCCESS  ??0003 Built Successfully!
    2018/12/05 11:10:03 INFO     ??0004 Restarting 'webad'...
    2018/12/05 11:10:03 SUCCESS  ??0005 './webad' is running...
    2018/12/05 11:10:03.937 [I] [asm_amd64.s:1333]  http server Running on http://:6789

- 訪問頁面

![](http://i2.51cto.com/images/blog/201812/05/28e0ce8fe16b20be860f19b42f4c0008.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章