3. So good
● Go commands
○ go build
○ go run
○ go fmt
○ go test
○ go get
○ etc.
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. So good: go test
$ ls
foo.go foo_test.go
$ go test
PASS
ok _/path/to/src/foo 0.027s
7. Not so good (for me)
● Library
○ The standard library
(In genaral, good enough for writing code, but...)
○ Third-party libraries
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. <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)
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/