Go 1.5 Release Notes
Introduction to Go 1.5
The latest Go release, version 1.5,is a significant release, including major architectural changes to the implementation.Despite that, we expect almost all Go programs to continue to compile and run as before,because the release still maintains the Go 1promiseof compatibility.
The biggest developments in the implementation are:
- The compiler and runtime are now written entirely in Go (with a little assembler).C is no longer involved in the implementation, and so the C compiler that wasonce necessary for building the distribution is gone.
- The garbage collector is nowconcurrent and provides dramatically lowerpause times by running, when possible, in parallel with other goroutines.
- By default, Go programs run with
GOMAXPROCSset to thenumber of cores available; in prior releases it defaulted to 1. - Support forinternal packagesis now provided for all repositories, not just the Go core.
- The
gocommand now providesexperimentalsupport for “vendoring” external dependencies. - A new
go tool tracecommand supports fine-grainedtracing of program execution. - A new
go doccommand (distinct fromgodoc)is customized for command-line use.
These and a number of other changes to the implementation and toolsare discussed below.
The release also contains one small language change involving map literals.
Finally, the timing of thereleasestrays from the usual six-month interval,both to provide more time to prepare this major release and to shift the schedule thereafter totime the release dates more conveniently.
Changes to the language
Map literals
Due to an oversight, the rule that allowed the element type to be elided from slice literals was notapplied to map keys.This has beencorrected in Go 1.5.An example will make this clear.As of Go 1.5, this map literal,
m := map[Point]string{ Point{29.935523, 52.891566}: "Persepolis", Point{-25.352594, 131.034361}: "Uluru", Point{37.422455, -122.084306}: "Googleplex",}may be written as follows, without thePoint type listed explicitly:
m := map[Point]string{ {29.935523, 52.891566}: "Persepolis", {-25.352594, 131.034361}: "Uluru", {37.422455, -122.084306}: "Googleplex",}The Implementation
No more C
The compiler and runtime are now implemented in Go and assembler, without C.The only C source left in the tree is related to testing or tocgo.There was a C compiler in the tree in 1.4 and earlier.It was used to build the runtime; a custom compiler was necessary in part toguarantee the C code would work with the stack management of goroutines.Since the runtime is in Go now, there is no need for this C compiler and it is gone.Details of the process to eliminate C are discussedelsewhere.
The conversion from C was done with the help of custom tools created for the job.Most important, the compiler was actually moved by automatic translation ofthe C code into Go.It is in effect the same program in a different language.It is not a new implementationof the compiler so we expect the process will not have introduced new compilerbugs.An overview of this process is available in the slides forthis presentation.
Compiler and tools
Independent of but encouraged by the move to Go, the names of the tools have changed.The old names6g,8g and so on are gone; instead thereis just one binary, accessible asgotoolcompile,that compiles Go source into binaries suitable for the architecture and operating systemspecified by$GOARCH and$GOOS.Similarly, there is now one linker (gotoollink)and one assembler (gotoolasm).The linker was translated automatically from the old C implementation,but the assembler is a new native Go implementation discussedin more detail below.
Similar to the drop of the names6g,8g, and so on,the output of the compiler and assembler are now given a plain.o suffixrather than.8,.6, etc.
Garbage collector
The garbage collector has been re-engineered for 1.5 as part of the developmentoutlined in thedesign document.Expected latencies are much lower than with the collectorin prior releases, through a combination of advanced algorithms,betterscheduling of the collector,and running more of the collection in parallel with the user program.The “stop the world” phase of the collectorwill almost always be under 10 milliseconds and usually much less.
For systems that benefit from low latency, such as user-responsive web sites,the drop in expected latency with the new collector may be important.
Details of the new collector were presented in atalk at GopherCon 2015.
Runtime
In Go 1.5, the order in which goroutines are scheduled has been changed.The properties of the scheduler were never defined by the language,but programs that depend on the scheduling order may be brokenby this change.We have seen a few (erroneous) programs affected by this change.If you have programs that implicitly depend on the schedulingorder, you will need to update them.
Another potentially breaking change is that the runtime nowsets the default number of threads to run simultaneously,defined byGOMAXPROCS, to the numberof cores available on the CPU.In prior releases the default was 1.Programs that do not expect to run with multiple cores maybreak inadvertently.They can be updated by removing the restriction or by settingGOMAXPROCS explicitly.For a more detailed discussion of this change, seethedesign document.
Build
Now that the Go compiler and runtime are implemented in Go, a Go compilermust be available to compile the distribution from source.Thus, to build the Go core, a working Go distribution must already be in place.(Go programmers who do not work on the core are unaffected by this change.)Any Go 1.4 or later distribution (includinggccgo) will serve.For details, see thedesign document.
Ports
Due mostly to the industry’s move away from the 32-bit x86 architecture,the set of binary downloads provided is reduced in 1.5.A distribution for the OS X operating system is provided only for theamd64 architecture, not386.Similarly, the ports for Snow Leopard (Apple OS X 10.6) still work but are nolonger released as a download or maintained since Apple no longer maintains that versionof the operating system.Also, thedragonfly/386 port is no longer supported at allbecause DragonflyBSD itself no longer supports the 32-bit 386 architecture.
There are however several new ports available to be built from source.These includedarwin/arm anddarwin/arm64.The new portlinux/arm64 is mostly in place, butcgois only supported using external linking.
Also available as experiments areppc64andppc64le (64-bit PowerPC, big- and little-endian).Both these ports supportcgo butonly with internal linking.
On FreeBSD, Go 1.5 requires FreeBSD 8-STABLE+ because of its new use of theSYSCALL instruction.
On NaCl, Go 1.5 requires SDK version pepper-41. Later pepper versions are notcompatible due to the removal of the sRPC subsystem from the NaCl runtime.
On Darwin, the use of the system X.509 certificate interface can be disabledwith theios build tag.
The Solaris port now has full support for cgo and the packagesnet andcrypto/x509,as well as a number of other fixes and improvements.
Tools
Translating
As part of the process to eliminate C from the tree, the compiler andlinker were translated from C to Go.It was a genuine (machine assisted) translation, so the new programs are essentiallythe old programs translated rather than new ones with new bugs.We are confident the translation process has introduced few if any new bugs,and in fact uncovered a number of previously unknown bugs, now fixed.
The assembler is a new program, however; it is described below.
Renaming
The suites of programs that were the compilers (6g,8g, etc.),the assemblers (6a,8a, etc.),and the linkers (6l,8l, etc.)have each been consolidated into a single tool that is configuredby the environment variablesGOOS andGOARCH.The old names are gone; the new tools are available through thegotoolmechanism asgo tool compile,go tool asm,and go tool link.Also, the file suffixes.6,.8, etc. for theintermediate object files are also gone; now they are just plain.o files.
For example, to build and link a program on amd64 for Darwinusing the tools directly, rather than throughgo build,one would run:
$ export GOOS=darwin GOARCH=amd64$ go tool compile program.go$ go tool link program.oMoving
Because thego/types packagehas now moved into the main repository (see below),thevet andcovertools have also been moved.They are no longer maintained in the externalgolang.org/x/tools repository,although (deprecated) source still resides there for compatibility with old releases.
Compiler
As described above, the compiler in Go 1.5 is a single Go program,translated from the old C source, that replaces6g,8g,and so on.Its target is configured by the environment variablesGOOS andGOARCH.
The 1.5 compiler is mostly equivalent to the old,but some internal details have changed.One significant change is that evaluation of constants now usesthemath/big packagerather than a custom (and less well tested) implementation of high precisionarithmetic.We do not expect this to affect the results.
For the amd64 architecture only, the compiler has a new option,-dynlink,that assists dynamic linking by supporting references to Go symbolsdefined in external shared libraries.
Assembler
Like the compiler and linker, the assembler in Go 1.5 is a single programthat replaces the suite of assemblers (6a,8a, etc.) and the environment variablesGOARCH andGOOSconfigure the architecture and operating system.Unlike the other programs, the assembler is a wholly new programwritten in Go.
The new assembler is very nearly compatible with the previousones, but there are a few changes that may affect someassembler source files.See the updatedassembler guidefor more specific information about these changes. In summary:
First, the expression evaluation used for constants is a littledifferent.It now uses unsigned 64-bit arithmetic and the precedenceof operators (+,-,<<, etc.)comes from Go, not C.We expect these changes to affect very few programs butmanual verification may be required.
Perhaps more important is that on machines whereSP orPC is only an aliasfor a numbered register,such asR13 for the stack pointer andR15 for the hardware program counteron ARM,a reference to such a register that does not include a symbolis now illegal.For example,SP and4(SP) areillegal butsym+4(SP) is fine.On such machines, to refer to the hardware register use itstrueR name.
One minor change is that some of the old assemblerspermitted the notation
constant=valueto define a named constant.Since this is always possible to do with the traditionalC-like#define notation, which is stillsupported (the assembler includes an implementationof a simplified C preprocessor), the feature was removed.
Linker
The linker in Go 1.5 is now one Go program,that replaces6l,8l, etc.Its operating system and instruction set are specifiedby the environment variablesGOOS andGOARCH.
There are several other changes.The most significant is the addition of a-buildmode option thatexpands the style of linking; it now supportssituations such as building shared libraries and allowing other languagesto call into Go libraries.Some of these were outlined in adesign document.For a list of the available build modes and their use, run
$ go help buildmodeAnother minor change is that the linker no longer records build time stamps inthe header of Windows executables.Also, although this may be fixed, Windows cgo executables are missing someDWARF information.
Finally, the-X flag, which takes two arguments,as in
-X importpath.name valuenow also accepts a more common Go flag style with a single argumentthat is itself aname=value pair:
-X importpath.name=valueAlthough the old syntax still works, it is recommended that uses of thisflag in scripts and the like be updated to the new form.
Go command
Thego command’s basic operationis unchanged, but there are a number of changes worth noting.
The previous release introduced the idea of a directory internal to a packagebeing unimportable through thego command.In 1.4, it was tested with the introduction of some internal elementsin the core repository.As suggested in thedesign document,that change is now being made available to all repositories.The rules are explained in the design document, but in summary anypackage in or under a directory namedinternal maybe imported by packages rooted in the same subtree.Existing packages with directory elements namedinternal may beinadvertently broken by this change, which was why it was advertisedin the last release.
Another change in how packages are handled is the experimentaladdition of support for “vendoring”.For details, see the documentation for thego commandand thedesign document.
There have also been several minor changes.Read thedocumentation for full details.
- SWIG support has been updated such that
.swigand.swigcxxnow require SWIG 3.0.6 or later. - The
installsubcommand now removes thebinary created by thebuildsubcommandin the source directory, if present,to avoid problems having two binaries present in the tree. - The
std(standard library) wildcard package namenow excludes commands.A newcmdwildcard covers the commands. - A new
-asmflagsbuild optionsets flags to pass to the assembler.However,the-ccflagsbuild option has been dropped;it was specific to the old, now deleted C compiler . - A new
-buildmodebuild optionsets the build mode, described above. - A new
-pkgdirbuild optionsets the location of installed package archives,to help isolate custom builds. - A new
-toolexecbuild optionallows substitution of a different command to invokethe compiler and so on.This acts as a custom replacement forgo tool. - The
testsubcommand now has a-countflag to specify how many times to run each test and benchmark.Thetestingpackagedoes the work here, through the-test.countflag. - The
generatesubcommand has a couple of new features.The-runoption specifies a regular expression to select which directivesto execute; this was proposed but never implemented in 1.4.The executing pattern now has access to two new environment variables:$GOLINEreturns the source line number of the directiveand$DOLLARexpands to a dollar sign. - The
getsubcommand now has a-insecureflag that must be enabled if fetching from an insecure repository, one thatdoes not encrypt the connection.
Go vet command
Thego tool vet command now doesmore thorough validation of struct tags.
Trace command
A new tool is available for dynamic execution tracing of Go programs.The usage is analogous to how the test coverage tool works.Generation of traces is integrated intogo test,and then a separate execution of the tracing tool itself analyzes the results:
$ go test -trace=trace.out path/to/package$ go tool trace [flags] pkg.test trace.outThe flags enable the output to be displayed in a browser window.For details, rungo tool trace -help.There is also a description of the tracing facility in thistalkfrom GopherCon 2015.
Go doc command
A few releases back, thego doccommand was deleted as being unnecessary.One could always run “godoc .” instead.The 1.5 release introduces a newgo doccommand with a more convenient command-line interface thangodoc’s.It is designed for command-line usage specifically, and provides a morecompact and focused presentation of the documentation for a packageor its elements, according to the invocation.It also provides case-insensitive matching andsupport for showing the documentation for unexported symbols.For details run “go help doc”.
Cgo
When parsing#cgo lines,the invocation${SRCDIR} is nowexpanded into the path to the source directory.This allows options to be passed to thecompiler and linker that involve file paths relative to thesource code directory. Without the expansion the paths would beinvalid when the current working directory changes.
Solaris now has full cgo support.
On Windows, cgo now uses external linking by default.
When a C struct ends with a zero-sized field, but the struct itself isnot zero-sized, Go code can no longer refer to the zero-sized field.Any such references will have to be rewritten.
Performance
As always, the changes are so general and varied that precise statementsabout performance are difficult to make.The changes are even broader ranging than usual in this release, whichincludes a new garbage collector and a conversion of the runtime to Go.Some programs may run faster, some slower.On average the programs in the Go 1 benchmark suite run a few percent faster in Go 1.5than they did in Go 1.4,while as mentioned above the garbage collector’s pauses aredramatically shorter, and almost always under 10 milliseconds.
Builds in Go 1.5 will be slower by a factor of about two.The automatic translation of the compiler and linker from C to Go resulted inunidiomatic Go code that performs poorly compared to well-written Go.Analysis tools and refactoring helped to improve the code, but much remains to be done.Further profiling and optimization will continue in Go 1.6 and future releases.For more details, see theseslidesand associatedvideo.
Standard library
Flag
The flag package’sPrintDefaultsfunction, and method onFlagSet,have been modified to create nicer usage messages.The format has been changed to be more human-friendly and in the usagemessages a word quoted with `backquotes` is taken to be the name of theflag’s operand to display in the usage message.For instance, a flag created with the invocation,
cpuFlag = flag.Int("cpu", 1, "run `N` processes in parallel")will show the help message,
-cpu N run N processes in parallel (default 1)Also, the default is now listed only when it is not the zero value for the type.
Floats in math/big
Themath/big packagehas a new, fundamental data type,Float,which implements arbitrary-precision floating-point numbers.AFloat value is represented by a boolean sign,a variable-length mantissa, and a 32-bit fixed-size signed exponent.The precision of aFloat (the mantissa size in bits)can be specified explicitly or is otherwise determined by the firstoperation that creates the value.Once created, the size of aFloat’s mantissa may be modified with theSetPrec method.Floats support the concept of infinities, such as are created byoverflow, but values that would lead to the equivalent of IEEE 754 NaNstrigger a panic.Float operations support all IEEE-754 rounding modes.When the precision is set to 24 (53) bits,operations that stay within the range of normalizedfloat32(float64)values produce the same results as the corresponding IEEE-754arithmetic on those values.
Go types
Thego/types packageup to now has been maintained in thegolang.org/xrepository; as of Go 1.5 it has been relocated to the main repository.The code at the old location is now deprecated.There is also a modest API change in the package, discussed below.
Associated with this move, thego/constantpackage also moved to the main repository;it wasgolang.org/x/tools/exact before.Thego/importer packagealso moved to the main repository,as well as some tools described above.
Net
The DNS resolver in the net package has almost always usedcgo to accessthe system interface.A change in Go 1.5 means that on most Unix systems DNS resolutionwill no longer requirecgo, which simplifies executionon those platforms.Now, if the system’s networking configuration permits, the native Go resolverwill suffice.The important effect of this change is that each DNS resolution occupies a goroutinerather than a thread,so a program with multiple outstanding DNS requests will consume fewer operatingsystem resources.
The decision of how to run the resolver applies at run time, not build time.Thenetgo build tag that has been used to enforce the useof the Go resolver is no longer necessary, although it still works.A newnetcgo build tag forces the use of thecgo resolver atbuild time.To forcecgo resolution at run time setGODEBUG=netdns=cgo in the environment.More debug options are documentedhere.
This change applies to Unix systems only.Windows, Mac OS X, and Plan 9 systems behave as before.
Reflect
Thereflect packagehas two new functions:ArrayOfandFuncOf.These functions, analogous to the extantSliceOf function,create new types at runtime to describe arrays and functions.
Hardening
Several dozen bugs were found in the standard librarythrough randomized testing with thego-fuzz tool.Bugs were fixed in thearchive/tar,archive/zip,compress/flate,encoding/gob,fmt,html/template,image/gif,image/jpeg,image/png, andtext/template,packages.The fixes harden the implementation against incorrect and malicious inputs.
Minor changes to the library
- The
archive/zippackage’sWritertype now has aSetOffsetmethod to specify the location within the output stream at which to write the archive. - The
Readerin thebufiopackage now has aDiscardmethod to discard data from the input. - In the
bytespackage,theBuffertypenow has aCapmethodthat reports the number of bytes allocated within the buffer.Similarly, in both thebytesandstringspackages,theReadertype now has aSizemethod that reports the original length of the underlying slice or string. - Both the
bytesandstringspackagesalso now have aLastIndexBytefunction that locates the rightmost byte with that value in the argument. - The
cryptopackagehas a new interface,Decrypter,that abstracts the behavior of a private key used in asymmetric decryption. - In the
crypto/cipherpackage,the documentation for theStreaminterface has been clarified regarding the behavior when the source and destination aredifferent lengths.If the destination is shorter than the source, the method will panic.This is not a change in the implementation, only the documentation. - Also in the
crypto/cipherpackage,there is now support for nonce lengths other than 96 bytes in AES’s Galois/Counter mode (GCM),which some protocols require. - In the
crypto/ellipticpackage,there is now aNamefield in theCurveParamsstruct,and the curves implemented in the package have been given names.These names provide a safer way to select a curve, as opposed toselecting its bit size, for cryptographic systems that are curve-dependent. - Also in the
crypto/ellipticpackage,theUnmarshalfunctionnow verifies that the point is actually on the curve.(If it is not, the function returns nils).This change guards against certain attacks. - The
crypto/sha512package now has support for the two truncated versions ofthe SHA-512 hash algorithm, SHA-512/224 and SHA-512/256. - The
crypto/tlspackageminimum protocol version now defaults to TLS 1.0.The old default, SSLv3, is still available throughConfigif needed. - The
crypto/tlspackagenow supports Signed Certificate Timestamps (SCTs) as specified in RFC 6962.The server serves them if they are listed in theCertificatestruct,and the client requests them and exposes them, if present,in itsConnectionStatestruct. - The stapled OCSP response to a
crypto/tlsclient connection,previously only available via theOCSPResponsemethod,is now exposed in theConnectionStatestruct. - The
crypto/tlsserver implementationwill now always call theGetCertificatefunction intheConfigstructto select a certificate for the connection when none is supplied. - Finally, the session ticket keys in the
crypto/tlspackagecan now be changed while the server is running.This is done through the newSetSessionTicketKeysmethod of theConfigtype. - In the
crypto/x509package,wildcards are now accepted only in the leftmost label as defined inthe specification. - Also in the
crypto/x509package,the handling of unknown critical extensions has been changed.They used to cause parse errors but now they are parsed and caused errors onlyinVerify.The new fieldUnhandledCriticalExtensionsofCertificaterecords these extensions. - The
DBtype of thedatabase/sqlpackagenow has aStatsmethodto retrieve database statistics. - The
debug/dwarfpackage has extensive additions to better support DWARF version 4.See for example the definition of the new typeClass. - The
debug/dwarfpackagealso now supports decoding of DWARF line tables. - The
debug/elfpackage now has support for the 64-bit PowerPC architecture. - The
encoding/base64packagenow supports unpadded encodings through two new encoding variables,RawStdEncodingandRawURLEncoding. - The
encoding/jsonpackagenow returns anUnmarshalTypeErrorif a JSON value is not appropriate for the target variable or componentto which it is being unmarshaled. - The
encoding/json’sDecodertype has a new method that provides a streaming interface for decodinga JSON document:Token.It also interoperates with the existing functionality ofDecode,which will continue a decode operation already started withDecoder.Token. - The
flagpackagehas a new function,UnquoteUsage,to assist in the creation of usage messages using the new conventiondescribed above. - In the
fmtpackage,a value of typeValuenowprints what it holds, rather than use thereflect.Value’sStringermethod, which produces things like<int Value>. - The
EmptyStmttypein thego/astpackage nowhas a booleanImplicitfield that records whether thesemicolon was implicitly added or was present in the source. - For forward compatibility the
go/buildpackagereservesGOARCHvalues for a number of architectures that Go might support one day.This is not a promise that it will.Also, thePackagestructnow has aPkgTargetRootfield that stores thearchitecture-dependent root directory in which to install, if known. - The (newly migrated)
go/typespackage allows one to control the prefix attached to package-level names usingthe newQualifierfunction type as an argument to several functions. This is an API change forthe package, but since it is new to the core, it is not breaking the Go 1 compatibilityrules since code that uses the package must explicitly ask for it at its new location.To update, rungo fixon your package. - In the
imagepackage,theRectangletypenow implements theImageinterface,so aRectanglecan serve as a mask when drawing. - Also in the
imagepackage,to assist in the handling of some JPEG images,there is now support for 4:1:1 and 4:1:0 YCbCr subsampling and basicCMYK support, represented by the newimage.CMYKstruct. - The
image/colorpackageadds basic CMYK support, through the newCMYKstruct,theCMYKModelcolor model, and theCMYKToRGBfunction, asneeded by some JPEG images. - Also in the
image/colorpackage,the conversion of aYCbCrvalue toRGBAhas become more precise.Previously, the low 8 bits were just an echo of the high 8 bits;now they contain more accurate information.Because of the echo property of the old code, the operationuint8(r)to extract an 8-bit red value worked, but is incorrect.In Go 1.5, that operation may yield a different value.The correct code is, and always was, to select the high 8 bits:uint8(r>>8).Incidentally, theimage/drawpackageprovides better support for such conversions; seethis blog postfor more information. - Finally, as of Go 1.5 the closest match check in
Indexnow honors the alpha channel. - The
image/gifpackageincludes a couple of generalizations.A multiple-frame GIF file can now have an overall bounds differentfrom all the contained single frames’ bounds.Also, theGIFstructnow has aDisposalfieldthat specifies the disposal method for each frame. - The
iopackageadds aCopyBufferfunctionthat is likeCopybutuses a caller-provided buffer, permitting control of allocation and buffer size. - The
logpackagehas a newLUTCflagthat causes time stamps to be printed in the UTC time zone.It also adds aSetOutputmethodfor user-created loggers. - In Go 1.4,
Maxwas not detecting all possible NaN bit patterns.This is fixed in Go 1.5, so programs that usemath.Maxon data including NaNs may behave differently,but now correctly according to the IEEE754 definition of NaNs. - The
math/bigpackageadds a newJacobifunction for integers and a newModSqrtmethod for theInttype. - The mime packageadds a new
WordDecodertypeto decode MIME headers containing RFC 204-encoded words.It also providesBEncodingandQEncodingas implementations of the encoding schemes of RFC 2045 and RFC 2047. - The
mimepackage also adds anExtensionsByTypefunction that returns the MIME extensions know to be associated with a given MIME type. - There is a new
mime/quotedprintablepackage that implements the quoted-printable encoding defined by RFC 2045. - The
netpackage will nowDialhostnames by trying eachIP address in order until one succeeds.TheDialer.DualStackmode now implements Happy Eyeballs(RFC 6555) by giving thefirst address family a 300ms head start; this value can be overridden bythe newDialer.FallbackDelay. - A number of inconsistencies in the types returned by errors in the
netpackage have beentidied up.Most now return anOpErrorvaluewith more information than before.Also, theOpErrortype now includes aSourcefield that holds the localnetwork address. - The
net/httppackage nowhas support for setting trailers from a serverHandler.For details, see the documentation forResponseWriter. - There is a new method to cancel a
net/httpRequestby setting the newRequest.Cancelfield.It is supported byhttp.Transport.TheCancelfield’s type is compatible with thecontext.Context.Donereturn value. - Also in the
net/httppackage,there is code to ignore the zeroTimevaluein theServeContentfunction.As of Go 1.5, it now also ignores a time value equal to the Unix epoch. - The
net/http/fcgipackageexports two new errors,ErrConnClosedandErrRequestAborted,to report the corresponding error conditions. - The
net/http/cgipackagehad a bug that mishandled the values of the environment variablesREMOTE_ADDRandREMOTE_HOST.This has been fixed.Also, starting with Go 1.5 the package sets theREMOTE_PORTvariable. - The
net/mailpackageadds anAddressParsertype that can parse mail addresses. - The
net/smtppackagenow has aTLSConnectionStateaccessor to theClienttype that returns the client’s TLS state. - The
ospackagehas a newLookupEnvfunctionthat is similar toGetenvbut can distinguish between an empty environment variable and a missing one. - The
os/signalpackageadds newIgnoreandResetfunctions. - The
runtime,runtime/trace,andnet/http/pprofpackageseach have new functions to support the tracing facilities described above:ReadTrace,StartTrace,StopTrace,Start,Stop, andTrace.See the respective documentation for details. - The
runtime/pprofpackageby default now includes overall memory statistics in all memory profiles. - The
stringspackagehas a newComparefunction.This is present to provide symmetry with thebytespackagebut is otherwise unnecessary as strings support comparison natively. - The
WaitGroupimplementation inpackagesyncnow diagnoses code that races a call toAddagainst a return fromWait.If it detects this condition, the implementation panics. - In the
syscallpackage,the LinuxSysProcAttrstruct now has aGidMappingsEnableSetgroupsfield, made necessaryby security changes in Linux 3.19.On all Unix systems, the struct also has newForegroundandPgidfieldsto provide more control when exec’ing.On Darwin, there is now aSyscall9functionto support calls with too many arguments. - The
testing/quickwill nowgeneratenilvalues for pointer types,making it possible to use with recursive data structures.Also, the package now supports generation of array types. - In the
text/templateandhtml/templatepackages,integer constants too large to be represented as a Go integer now trigger aparse error. Before, they were silently converted to floating point, losingprecision. - Also in the
text/templateandhtml/templatepackages,a newOptionmethodallows customization of the behavior of the template during execution.The sole implemented option allows control over how a missing key ishandled when indexing a map.The default, which can now be overridden, is as before: to continue with an invalid value. - The
timepackage’sTimetype has a new methodAppendFormat,which can be used to avoid allocation when printing a time value. - The
unicodepackage and associatedsupport throughout the system has been upgraded from version 7.0 toUnicode 8.0.