2. Intro
•
was the GitHub Top 1
Contributor ( http://git.io/top )
•
3+ years Perl/VimL
programming
•
3+ years PHP programming
•
2+ years Go programming
9. What’s Go
•
Statically-Typed Language 靜態型別編譯語⾔言
•
Built-in Concurrency 內建並發性⽀支持
•
Statically-linked Native Binary 靜態連結原⽣生⼆二進位執⾏行檔
•
Fast compilation times 極快速的編譯
•
Remote package management 內建外部套件管理
•
Garbage Collection 使⽤用垃圾收集器
•
Safety 安全 (race conditions, type and memory safety for
multithreaded program)
10. About The Language
•
Concise variable declaration 簡潔的變數定義
•
Type Inference 型別推導
•
Easy to use 簡易使⽤用
•
Composition instead of Inheritance.
•
Use Interface 使⽤用介⾯面取代 is-a 繼承
•
multiple return value 多回傳值函數
11. About The Tools
•
語⾔言規格的修改,可透過 go fix 來將舊版語法或程式碼做⾃自
動修正
•
編碼⾵風格可透過 go fmt 來統⼀一所有格式,以及⾃自動去除空
⽩白⾏行、換⾏行、縮排等等。 且可以⽤用 grammar 的⽅方式來描述
語法。
•
內建 profiling tools 且⽀支持 Goole pprof ,可直接在 http
server 上開 profiler API,利⽤用命令列⼯工具遠端取得 CPU,
Memory 使⽤用狀況並進⾏行分析,或產⽣生 call graph 等等資
料。
•
遠端套件可直接透過 go get 安裝
16. Benchmark
•
Faster than Node.js, Python, Perl, PHP, Ruby
•
A bit slower than C, C++ and Java (sometimes
faster than Java)
•
Low memory footprint (10+ times lower than Java)
28. Just use Go Routine
•
Threaded worker pool
•
use pipeline (channel) to communicate
•
CSP (Communicating Sequential Processes)
http://golang.org/doc/faq
54. Go IDE
•
Sublime Text 2
•
IntelliJ
•
LiteIDE
•
Intype
•
NetBeans
•
Eclipse
•
Zeus
http://geekmonkey.org/articles/20-comparison-of-ides-forgoogle-go
55. go/misc
•
misc/vim : generic vim plugin
•
misc/emacs : emacs go mode
•
misc/git : pre-commit hook (run go fmt before commmit)
•
misc/bash : bash completion
•
zsh/go : zsh completion
•
misc/cgo : cgo examples
86. Struct
•
Exported fields starts with upper case letter.
•
Private fields starts with lower case letter.
•
Code in the same package can access private
fields and private functions.
•
External package can not access private fields
and private functions.