This is a creation in Article, where the information may have evolved or changed.
Go1.1.2 was officially released in 2013.08.12 for about 1 months.
The go language has entered the Go1.2 release process and is expected to be released by the end of 2013.
This article mainly lists some of the major improvements in Go1.2 and will continue to keep up to date.
Changes in language
Disable Nil object values
For Go1.0, the following code is available:
?
1 2 3 4 5 6 7 8 |
type T struct { x [ ] 1 24 byte Field int32 }
func main() { var x *T } |
The operation x.Field
will correspond to 1<<24
the memory of the location.
In Go1.2, this will cause panic
or error.
Slice syntax increases the CAP field
Before slicing, the cap defaults to maximum.
Like what:
?
1 2 |
10 int slice := array[ 2 : 4 ] |
slice
The capacity is 8. In Go1.2, if you want to have a capacity of 6, you can:
?
If the start address of the first part is omitted, the default is 0.
With the customizable cap syntax, you can create your own new large memory and then construct the Malloc/free memory management function yourself.
The cap for slice returned by malloc is strictly limited to the size requested.
Design document for this syntax: https://docs.google.com/document/d/1GKKdiGYAghXRxC2BFrSEbHBZZgAGKQ-yXK-hRKBo0Kk/pub
CGO Support C + + source code
CGO supports function pointers, please refer to https://code.google.com/p/go/source/browse/misc/cgo/test/fpvar.gofor usage.
CGO supports C + + syntax, but only C-language import symbols are supported.
Added CPPFLAGS
and parameter setting options for C + + CXXFLAGS
.
More suitable for C-language export, but in C + + implementation of the library.
Note: The Windows version of MinGW also does not support external links, please refer to Issue6533for details.
Changes in runtime implementations
The function entry of Goroutines adopts preemptive scheduling.
In previous versions, if there was a dead loop inside the Goroutines,
Then other goroutines may not be able to get CPU resources for this thread.
Especially when the Gomaxprocs is set to 1 threads.
This problem is partially fixed in Go1.2: the Scheduler
The entrance is occasionally triggered. In other words, if any loop
A non-inline function is called internally, and the other Goroutines
There will also be an opportunity to execute on the same thread.
In Go1.2, the default stack size for Goroutine is temporarily changed from 4KB to 8KB.
The newly changed 8KB size can bring some performance gains for many practical applications.
Of course, a larger default stack also causes the program to use more memory.
Better stack technology is used to solve this problem in the subsequent go development.
At the same time the Goroutine stack has the maximum limit (not infinite), the 64-bit system default limit is 1GB,
The 32-bit system model is limited to 250MB.
If you need to adjust the default values, you can call runtime/debug
the package's SetMaxStack
function modifications.
For details, please refer to: CL12541052
The maximum number of system threads opened by the program has been increased (default is 10000).
If you need to adjust the default values, you can call runtime/debug
the package's SetMaxThreads
function modifications.
For details, please refer to: CL13037043
About Dynamic Library Support
External links are already supported in the Linux/arm version.
This is a key part of the Go compiler tool chain that supports dynamic library features.
The state of Gccgo
Expect the GCC4.9 to contain the complete Go1.2. The current GCC4.8.2 contains Go1.1.2.
Performance optimization
Performance improvement of compress/bzip2:30%
Crypto/des:5-fold Performance improvement
Performance improvement for encoding/json:encoding 30%
Net:windows/bsd Network and runtime
deep integration (Linux/os X has been supported in Go1.1), 30% performance improvements
Changes to the standard library
The larger changes are:
Encoding: A new package that provides a common encoding
interface
FMT: The introduction of parametric index support, mainly to deal with the change of parameter order after the translation of different languages
Sync/atomic: Added a Swap
function
Text/template: Add eq
/ lt
equal comparison functions, add {{else if ... }}
simplified syntax
Runtime: Limit the parameter SetFinalizer
f
type of the parameter, as long as you can assign a value
Testing: Added TB
interface
image/gif
Added a encode
function
Md5/hash and other functions to increase convenience
New supported parameter index for FMT:
?
1 2 |
"a" ' B ' ' C ' // output: c a a b |
Simplified Hash Usage:
?
1 2 |
hash: = SHA1. Sum ([] ( "123" fmt. Printf ( "H ( data) =%x\n " |
Miscellaneous messages (Personal supplement)
Go command line tool migrated to go.tools
, and will greatly improve the layout
go.text/encoding
Added support for GBK, completely solve the Chinese Windows command line Chinese garbled problem.
go.image
Added BMP storage and block TIFF read support, and currently does not support large TIFF images.
notepad++ better highlighting, builtin function auto-completion, function/method list and other functions.