30
Go Workshop Day 0 2016/07/26

Go Workshop Day 0

Embed Size (px)

Citation preview

Go WorkshopDay 0

2016/07/26

Go Workshop 3 ( ) 10 ( )1 + 2 Web

• Go

• Web

• Go

• Go

Go2009/11/10

...2012/03/28 Go1...2015/08/19 Go1.52016/02/17 Go1.62016/07? Go1.7

Go 1simple & easyGo

Go 2

• import

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• OS

• GC OS

Go•

• GC

• 1MB

• Raspberry Pi

Go•

• Go DSL

• generics

Go

• Docker

• Go (1.5 Go Go )

• Origami

• Web

the Go WayGo

• GOPATH

• ( Windows )

• https://golang.org/dl/

• homebrew (Mac)

• brew install go

• apt, yum (Linux)

• ( )

Web

1.6

2 1.7

GOPATH

GOPATH Go

Go $GOPATH/src

GOPATHQ. A.

$HOME(win %HOME%)

GOPATH=$HOME/go GOPATH=$HOME

IDE

Editor IDE

IDE(

)

• Atom

• Visual Studio Code ( )

• IntelliJ

• Vim

IDE

gofmt

gofmt lint

• Go

• GOPATH

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)}

Go 1.7

• ( )

• test