Start basic go project on Ubuntu17.10

前端之家收集整理的这篇文章主要介绍了Start basic go project on Ubuntu17.10前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Install go

  1. sudo add-apt-repository ppa:longsleep/golang-backports
  2. sudo apt-get update
  3. sudo apt-get install golang-go

Check go env

  1. $ go env
  2. ...
  3. GOPATH="/home/<user>/go"
  4. GOROOT="/usr/lib/go-1.8"
  5. ...

GOPATH and GOROOT,

  • GOPATH是作为编译后二进制的存放目的地和import包时的搜索路径
  • GOROOT is your go install location.

There have more details for install

Install beego

Install

  1. go get github.com/astaxie/beego

Test install

  1. sudo nano test.go

Past this code

  1. package main
  2.  
  3. import "github.com/astaxie/beego"
  4.  
  5. func main() {
  6. beego.Run()
  7. }

then

  1. go build test.go
  2. ./test
  3. [I] http server Running on http://:8080

Finish~

Enjoy IT

猜你在找的Ubuntu相关文章