今天打開golang.org,驚喜發現golang 1.8發布了,果斷切換到1.8的開發環境。以下內容摘錄自官網
When explicitly converting a value from one struct type to another, as of Go 1.8 the tags are ignored. Thus two structs that differ only in their tags may be converted from one to the other:
func example() { type T1 struct { X int `json:"foo"` } type T2 struct { X int `json:"bar"` } var v1 T1 var v2 T2 v1 = T1(v2) // now legal}The language specification now only requires that implementations support up to 16-bit exponents in floating-point constants. This does not affect either the “gc” or gccgo compilers, both of which still support 32-bit exponents.
如果兩個結構體只有tag信息是不一樣的,可以直接強制轉換。
Garbage collection pauses should be significantly shorter than they were in Go 1.7, usually under 100 microseconds and often as low as 10 microseconds. See the document on eliminating stop-the-world stack re-scanning for details. More work remains for Go 1.9.
10us級別的STW,爽!
更多信息請參考https://golang.org/doc/go1.8
新聞熱點
疑難解答