Go WorkshopDay 0
2016/07/26
Go Workshop 3 ( ) 10 ( )1 + 2 Web
Go2009/11/10
...2012/03/28 Go1...2015/08/19 Go1.52016/02/17 Go1.62016/07? Go1.7
Go 1simple & easyGo
•
•
•
•
Go 31
1 1
Mac Win Linux
1
Go•
• (Docker, rkt)
• Worker Queue(NSQ)
• (rtop)
• CMS(Hugo)
Go• Web API, Web
•
• HTML JSON XML
API
• Go
•
Go• CLI ( , )
• 1
•
•
Go•
• GC
• 1MB
• Raspberry Pi
Go•
• Go DSL
•
• generics
Go
• Docker
• Go (1.5 Go Go )
• Origami
• Web
• ( Windows )
• https://golang.org/dl/
• homebrew (Mac)
• brew install go
• apt, yum (Linux)
•
• ( )
GOPATH
GOPATH Go
Go $GOPATH/src
GOPATHQ. A.
$HOME(win %HOME%)
GOPATH=$HOME/go GOPATH=$HOME
IDE(
)
• Atom
• Visual Studio Code ( )
• IntelliJ
• Vim
IDE
gofmt
gofmt lint
mkdir $GOPATH/src/hellomkdir $GOPATH/src/hello/greetingcd $GOPATH/src/hello
greeting/greeting.go
$GOPATH/src/hello/greeting/greeting.go
package greeting
import "fmt"
func Hello(name string) string { return fmt.Sprintf("Hello, %s!", name)}
main.go
$GOPATH/src/hello/main.go
package main
import ( "fmt" "net/http"
"hello/greeting")
func main(){ http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, greeting.Hello("Gopher")) }) http.ListenAndServe(":8080", nil)}