Here, we’ll help you understand Golang 1.15 key updates and improvements seen in the tooling, performance of the compiler and standard library.
Since its release, Golang has gained increasing popularity in the developer community. In 2009 and 2016, it was recognized as the language of the year. Currently, it holds the eleventh position on the TIOBE Programming Community index . Golang can be used for all kinds of software development solutions such as a system programming language, a general programming language, or general support. It can handle heavy server-centric web services, text-processing problems, and heavy-duty distributed applications.
What is Golang?
Golang, also known as Go, is an open-source programming language created by Google developers Robert Griesemer, Ken Thompson, and Rob Pike in 2007. Golang’s creators sought to create a statically typed compiled language that would be as easy to use as dynamically typed languages and have a similar level of expressiveness (i.e. conciseness as represented by the number of code lines needed to express a given concept). In other words, they wanted to combine C++ with Java and Python while capturing the best features from all of them. As a result, Golang has elements from both statically and dynamically typed languages. Golang syntax was designed to allow virtually everything to be programmed using minimal syntax. Although the language has been on the market for over a decade, it hasn’t introduced any serious syntax modifications that could make the code over-complicated. However, the language has been constantly revised and improved over the years. Golang 1.15, the 16th major version was released on 11 August 2020.
Julia Vs Python
Benchmarking and performance analysis of Julia Vs Python
Read More
What’s new with Golang 1.15?
Most of the changes in the latest version of Golang 1.15 can be seen in the tooling, the performance of the compiler, and in the standard library. In order to stay true to the Go compatibility promise, there haven’t been any significant changes in the language itself.
Golang 1.15 drops support for 32-bit binaries on macOS, iOS, iPadOS, watchOS, and tvOS (the darwin/386 and darwin/arm ports). Golang 1.15 continues to support the 64-bit darwin/amd64 and darwin/arm64 ports.
Some of the major changes that have been implemented in Golang 1.15 can be seen as follows:
Tools
- Go command: The GOPROXY environment now supports skipping proxies that return errors. Proxy URLs now can be separated with commas or pipe characters. Also, various flag parsing issues in
go test
and go vet
have been fixed.
- Vet: The vet tool now warns about conversions of the form string (x) where x has an integer type other than rune or byte. The vet tool also now warns about type assertions from one interface type to another interface type when the type assertion will always fail.
Runtime
- For the runtime, the allocation of small objects now works more efficiently at high counts and has lower worst-case latency. Further, non-blocking receives on closed channels now perform as well as non-blocking receives on open channels.
Compiler
- Package unsafe’s safety rules allow converting an unsafe.Pointer into uintptr when calling certain functions. Previously, in some cases, the compiler allowed multiple chained conversions. The compiler now requires exactly one conversion.
- Golang 1.15 includes a -spectre flag to both the compiler and the assembler
- The compiler now rejects //go: compiler directives that have no meaning for the declaration they are applied to with a “misplaced compiler directive” error.
- The compiler’s -json optimization logging now reports large (>= 128 byte) copies and provides explanations of escape analysis decisions.
Linker
One of the largest tooling changes in 1.15 is the completely rewritten linker. There are three major structural changes in the new linker:
- Moving work from the linker to the compiler: this enables parallelization, as compiles are done in parallel across multiple CPUs (or machines), but the link step almost always has to be done in serial at the end of the build. Additionally, the results of the compiler are cached by the Golang tooling.
- Improving key data structures, primarily by avoiding strings. The current linker uses a big symbol table indexed by string; the new design avoids strings as much as possible by using a symbol-numbering technique.
- Avoiding loading all input object files into memory at once: this makes the new linker use less memory for large programs, and allocate less memory overall (the current linker spends over 20% of its time in the garbage collector).
Golang 1.15 New Feature
- New embedded tzdata package: Golang 1.15 includes a new package, time/tzdata, that permits embedding the timezone database into a program.
- Cgo: Golang 1.15 will translate the C type EGLConfig to the Go type uintptr.
- X.509 CommonName deprecation: The deprecated, legacy behavior of treating the CommonName field on X.509 certificates as a host name when no Subject Alternative Names are present is now disabled by default.
Minor changes to the library
As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind.
- bufio: When a Scanner is used with an invalid io.Reader that incorrectly returns a negative number from Read, the Scanner will no longer panic, but will instead return the new error ErrBadReadCount.
- context: Creating a derived Context using a nil parent is now explicitly disallowed.
- crypto/ecdsa: The new SignASN1 and VerifyASN1 functions allow generating and verifying ECDSA signatures in the standard ASN.1 DER encoding.
- crypto/elliptic: The new MarshalCompressed and UnmarshalCompressed functions allow encoding and decoding NIST elliptic curve points in compressed format.
- crypto/rsa: VerifyPKCS1v15 now rejects invalid short signatures with missing leading zeroes, according to RFC 8017.
- crypto/tls: The new Dialer type and its DialContext method permit using a context to both connect and handshake with a TLS server.
- crypto/x509: If either the name on the certificate or the name being verified (with VerifyOptions.DNSName or VerifyHostname) are invalid, they will now be compared case-insensitively without further processing (without honoring wildcards or stripping trailing dots).
- crypto/x509/pkix: Name.String now prints non-standard attributes from Names if ExtraNames is nil.
- database/sql: The new DB.SetConnMaxIdleTime method allows removing a connection from the connection pool after it has been idle for a period of time, without regard to the total lifespan of the connection.
- database/sql/driver: The new Validator interface may be implemented by Conn to allow drivers to signal if a connection is valid or if it should be discarded.
- debug/pe: The package now defines the IMAGE_FILE, IMAGE_SUBSYSTEM, and IMAGE_DLLCHARACTERISTICS constants used by the PE file format.
- encoding/asn1: Marshal now sorts the components of SET OF according to X.690 DER. Unmarshal now rejects tags and Object Identifiers which are not minimally encoded according to X.690 DER.
- encoding/json: The package now has an internal limit to the maximum depth of nesting when decoding. This reduces the possibility that a deeply nested input could use large quantities of stack memory, or even cause a “goroutine stack exceeds limit” panic.
- Flag: When the flag package sees -h or -help, and those flags are not defined, it now prints a usage message. If the FlagSet was created with ExitOnError, FlagSet.Parse would then exit with a status of 2. In this release, the exit status for -h or -help has been changed to 0. In particular, this applies to the default handling of command line flags.
- Fmt: The printing verbs %#g and %#G now preserves trailing zeros for floating-point values.
- go/format: The Source and Node functions now canonicalize number literal prefixes and exponents as part of formatting Golang source code.
- html/template: The package now uses Unicode escapes (\uNNNN) in all JavaScript and JSON contexts.
- io/ioutil: TempDir and TempFile now reject patterns that contain path separators. That is, calls such as ioutil.TempFile(“/tmp”, “../base*”) will no longer succeed.
- math/big: The new Int.FillBytes method allows serializing to fixed-size pre-allocated byte slices.
- math/cmplx: The functions in this package were updated to conform to the C99 standard (Annex G IEC 60559-compatible complex arithmetic) with respect to handling of special arguments such as infinity, NaN and signed zero.
- net: If an I/O operation exceeds a deadline set by the Conn.SetDeadline, Conn.SetReadDeadline, or Conn.SetWriteDeadline methods, it will now return an error that is or wraps os.ErrDeadlineExceeded.
- net/http: Parsing is now stricter as a hardening measure against request smuggling attacks: non-ASCII white space is no longer trimmed like SP and HTAB, and support for the “identity” Transfer-Encoding was dropped.
- net/http/httputil: ReverseProxy now supports not modifying the X-Forwarded-For header when the incoming Request.Header map entry for that field is nil.
- net/http/pprof: All profile endpoints now support a “seconds” parameter. When present, the endpoint profiles for the specified number of seconds and reports the difference.
- net/url: The new URL field RawFragment and method EscapedFragment provide detail about and control over the exact encoding of a particular fragment.
- os: If an I/O operation exceeds a deadline set by the File.SetDeadline, File.SetReadDeadline, or File.SetWriteDeadline methods, it will now return an error that is or wraps os.ErrDeadlineExceeded.
- plugin: DWARF generation is now supported (and enabled by default) for -buildmode=plugin on macOS.
- reflect: Package reflect now disallows accessing methods of all non-exported fields, whereas previously it allowed accessing those of non-exported, embedded fields.
- regexp: The new Regexp.SubexpIndex method returns the index of the first subexpression with the given name within the regular expression.
- runtime: Several functions, including ReadMemStats and GoroutineProfile, no longer block if a garbage collection is in progress.
- runtime/pprof: The goroutine profile now includes the profile labels associated with each goroutine at the time of profiling. This feature is not yet implemented for the profile reported with debug=2.
- strconv: FormatComplex and ParseComplex are added for working with complex numbers.
- sync: The new method Map.LoadAndDelete atomically deletes a key and returns the previous value if present.
- syscall: On Unix systems, functions that use SysProcAttr will now reject attempts to set both the Setctty and Foreground fields, as they both use the Ctty field but do so in incompatible ways.
- testing: The testing.T type now has a Deadline method that reports the time at which the test binary will have exceeded its timeout.
- text/template: JSEscape now consistently uses Unicode escapes (\u00XX), which are compatible with JSON.
- Time: The new method Ticker.Reset supports changing the duration of a ticker.
Golang uses GitHub issues to track all bugs and feature requests, so you can scan the list of closed issues in the Golang 1.15 milestone for further exploration of what’s in the release. If you have any other questions regarding Golang, feel free to contact us.
Facetagging with Elasticsearch
How to do face tagging and clustering in videos with Elasticsearch
Read More