Golang

Golang tutorials:
http://golangtutorials.blogspot.tw/2011/05/table-of-contents.html
http://higherordergo.blogspot.co.uk/2013/07/chapter-1.html

Go by example:
https://gobyexample.com/channel-directions

Go book:
http://www.golang-book.com/11

Go blog:
http://dave.cheney.net/tag/golang-3

Golang China:
http://my.oschina.net/chai2010/blog/119870

Sync. vs. Channel:
http://soniacodes.wordpress.com/2011/02/28/channels-vs-sync-package/

Golang synchronization (happens before)
http://golang.org/ref/mem

Go is not object oriented. It achieves through struct
Inheritance and subclassing is achieved through anonymous type, meaning embed struct inside another struct
Go can easily extends functionality through interface, any change to the core classes or core hierarchies.

Higher Order Function
Closure
Multiple return values

Pointers
http://www.golang-book.com/8

  • var ptr **int
    • ptr is a pointer
    • *ptr is also a pointer
    • **ptr is a value
  • var ptr *int
  • *ptr = 12
  • fmt.Println(*ptr) // Fail because the compiler can’t allocate ptr
  • var ptr *int
  • var a = 20
  • ptr = &a
  • *ptr = 35
  • fmt.Println(*ptr) // Success

Duck typing and interface{}:
http://hi.baidu.com/h2ero/item/fcb55f808c879ad05e0ec1a5

Go test showing log :
go test -v filename

Go test coverage
go test -coverprofile=/tmp/out
go tool cover -func=/tmp/out
or
go tool cover -html=/tmp/out

io.Writer (implements writer interface Write(p []byte) (n int, err error)):
http.Request struct
http.Conn interface

var r io.Reader
r = os.Stdin
r = bufio.NewReader(r)
r = new(bytes.Buffer)
// and so on

io.Reader
http.Conn interface

Write data through network:
l, e := net.Listen(“tcp", “127.0.0.1:0″)  //l = net.Listener, e = address
conn, err := l.Accept()  // conn = net.connection
wBuf := bufio.NewWriter(conn)  // wBuf = *bufio.Writer
wBuf.Flush()  // Write through network

Pass parameters to go test:
go test –port=""

Go test a particular function
go test -test.bench NameOfTestFunction

廣告
本篇發表於 Uncategorized。將永久鏈結加入書籤。

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s