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.

First impressions of Go

1,200 views

Published on

Published in: Software, Technology, Education
  • Login to see the comments

  • Be the first to like this

First impressions of Go

  1. 1. First impressions of Go OGAWA Yusaku
  2. 2. About me ● OGAWA Yusaku ● HDE, Inc. ● Newbie gopher
  3. 3. So good ● Go commands ○ go build ○ go run ○ go fmt ○ go test ○ go get ○ etc.
  4. 4. So good: go fmt $ go fmt main.go <Before> <After> package main import "fmt" func main(){ sum:=0 for i:=0;i<10;i++{sum+=i} fmt.Println(sum) } package main import "fmt" func main() { sum := 0 for i := 0; i < 10; i++ { sum += i } fmt.Println(sum) }
  5. 5. So good: go test $ ls foo.go foo_test.go $ go test PASS ok _/path/to/src/foo 0.027s
  6. 6. Good habit
  7. 7. Not so good (for me) ● Library ○ The standard library (In genaral, good enough for writing code, but...) ○ Third-party libraries
  8. 8. Not so good: The standard library ● net/mail (Mail parsing library) http://golang.org/pkg/net/mail/ eml, _ := os.Open("hello.eml") msg, _ := mail.ReadMessage(eml) msg.Header.Get("Subject")
  9. 9. <Mail> Received: from example.net ([x.x.x.x]) by example.org (foo); Fri, 30 May 2014 00:00:00 +0900 (JST) Received: from example.com ([y.y.y.y]) by example.net (bar); Fri, 30 May 2014 00:00:00 +0900 (JST) Date: Fri, 30 May 2014 00:00:00 +0900 From: from <from@example.com> Subject: This is a subject header Hello <Output> msg.Header.Get("Subject") => This is a subject header msg.Header.Get("Received") => Received: from example.net ([x.x.x.x]) by example.org (foo); Fri, 30 May 2014 00:00:00 +0900 (JST)
  10. 10. http://golang.org/src/pkg/net/mail/message.go#L103 103 104 // A Header represents the key-value pairs in a mail message header. 105 type Header map[string][]string 106
  11. 11. <UTF-8> =?UTF-8?B?SGVsbG8sIEdvbGFuZy4=?= => Hello, Golang. <ISO-2022-JP> =?ISO-2022-JP?B?GyRCJE8kbSE8GyhCLCBHb2xhbmcu?= => Error: missing word in phrase http://golang.org/src/pkg/net/mail/message.go#L445 445 charset, enc := strings.ToLower(fields[1]), strings.ToLower(fields[2]) 446 if charset != "iso-8859-1" && charset != "utf-8" { 447 return "", fmt.Errorf("mail: charset not supported: %q", charset) 448 }
  12. 12. Not so good: Thirt-party libraries There are too many standards ● e.g. Iconv bindings for Go ○ github.com/qiniu/iconv ○ github.com/djimenez/iconv-go ○ github.com/xushiwei/go-iconv ○ github.com/hwch/iconv ○ github.com/xuyu/iconv ○ github.com/erkl/iconv ○ github.com/moovweb/goconv ○ github.com/ChaimHong/go-iconv ○ github.com/zhigangc/goconv ○ github.com/vedranvuk/bindiconv ○ github.com/jhiter/goiconv http://www.xkcd.com/927/
  13. 13. Thank you

×