golang notes(5)

After reading <Go in Action> and <Effective Go>, i am going to study the Go standard library next.

6/2, notes on builtin and runtime package:

slice.go, map.go and chan.go are of special interest within package runtime:

Slice append operation will call growslice if necessary, which returns the new slice.

 

 

How to get __FILE__ and __LINE__ similar to C/C++ in golang?

func file() string {
	_, file, _, _ := runtime.Caller(1)
	return file
}

func line() int {
	_, _, line, _ := runtime.Caller(1)
	return line
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章