Skip to content

Instantly share code, notes, and snippets.

@blanklin030
Last active December 20, 2018 09:22
Show Gist options
  • Save blanklin030/158924a266c8b6976a2b0aa6d3467fa9 to your computer and use it in GitHub Desktop.
Save blanklin030/158924a266c8b6976a2b0aa6d3467fa9 to your computer and use it in GitHub Desktop.
install go at mac os

install go

download from this url:https://golang.org/dl/

check if install success

go version
ll /usr/local/go

set config

vim ~/.bash_profile

export GOROOT=/usr/local/go
export GOPATH=/Users/blank/Documents/docker/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

source ~/.bash_profile

install beego

go get github.com/astaxie/beego go get github.com/beego/bee

check beego

______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.10.0

├── Beego     : 1.11.1
├── GoVersion : go1.11.4
├── GOOS      : darwin
├── GOARCH    : amd64
├── NumCPU    : 4
├── GOPATH    : /Users/blank/Documents/docker/go
├── GOROOT    : /usr/local/go
├── Compiler  : gc
└── Date      : Thursday, 20 Dec 2018

write a test file

mkdir /Users/blank/Documents/docker/go/apps touch test.go

package main
import "fmt"
func main(){
  fmt.Printf("hello world")
}

go run test.go

create a demo project by bee

bee new projectName

run the beego demo

cd /Users/blank/Documents/docker/go/src/demo

bee run 

create a api demo by bee

bee api projectName

run the beego demo

cd /Users/blank/Documents/docker/go/src/demo

//the cmd will open the swagger api doc
bee run -downdoc=true -gendoc=true

visit the url

http://localhost:8080/swagger/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment