Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Go Workshop Day 1

284 views

Published on

Go Workshop Day 1

Published in: Engineering
  • Be the first to comment

Go Workshop Day 1

  1. 1. Go Workshop 2016/09/14
  2. 2. • • Web
  3. 3. A Tour of Go https://go-tour-jp.appspot.com/welcome/1
  4. 4. Language Specification https://golang.org/ref/spec
  5. 5. Go Effective Go https://golang.org/doc/effective_go.html
  6. 6. A Tour of Go https://golang.org/doc/
  7. 7. Numeric(int, int8, float32, uint, etc...) String Array Slice Map Struct Pointer Function Interface
  8. 8. type struct
  9. 9. Struct type Name struct { First string Last string }
  10. 10. type email string type kvs map[string]string int
  11. 11. ( ) var fval float32 = 1.5 ival := int(fval) // type email string var m email = "test@example.com" s := string(m) type assertion
  12. 12. Function func Hello() string { return "hello" }
  13. 13. Method Type type Name struct { Field1 int field2 int } func (n *Name) FullName() string { return n.First + " " + n.Last }
  14. 14. Method struct type Tel string func (t Tel) IsMobile() bool { // return true }
  15. 15. Interface interface interface (implements ) type Printer interface { Print() string } type email string func (e email) Print() string { return e }
  16. 16. Web
  17. 17. Live Coding
  18. 18. package hello import ( "fmt" "net/http" ) func HelloHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello") } func main() { http.ListenAndServe(":7070", http.HandlerFunc(HelloHandler)) }
  19. 19. http.Handler http.Handler interface ServeHTTP(ResponseWriter, *Request) type Handler interface { ServeHTTP(ResponseWriter, *Request) } https://golang.org/src/net/http/server.go
  20. 20. http.HandlerFunc http.HandlerFunc func(ResponseWriter, *Request) ServeHTTP type HandlerFunc func(ResponseWriter, *Request) func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) { f(w, r) }
  21. 21. HackerNews API ( ) https://gist.github.com/kmtr/ cfb91bac834137bd5c3e6b0830170d02 HackerNews API https://github.com/HackerNews/API
  22. 22. Go http://pub.maruzen.co.jp/bookmagazine/bookdata/ search/9784621300251.html Go http://gihyo.jp/book/2016/978-4-7741-8392-3 A Tour of Go
  23. 23. https://github.com/comail/colog https://github.com/justinas/alice https://github.com/pressly/chi

×