DEV Community

Cover image for What’s New In Golang 1.15?
Solace Infotech Pvt. Ltd.
Solace Infotech Pvt. Ltd.

Posted on

What’s New In Golang 1.15?

Since its delivery, Golang has increased popularity in the developer community. Till the year 2016, it was crowned as the language of the year and holds 11th position in the TIOBE programming community index. Golang is used for all types of software development solutions like general programming language, system programming language or general support. It has the ability to handle heavy server-centric web services, text processing problems and heavy distributed apps. Since its release, the language has been constantly revised and improved over the years. Before proceeding for the new features and updates in Go 1.15, let us have a quick look at Golang.

What Is Golang?

Golang is also known as Go. It is an open source programming language developed by Google in the year 2007. Golang’s creators want to make a statically typed compiled language that would be as simple to use as dynamically typed languages and have a similar level of expressiveness. In short they want to include C++ with Java and Python while including the best features of them. So, Golang has elements from statistically and dynamically typed languages. Golang syntax was designed to allow virtually everything to be programmed using less syntax. Even though the language has been available for longer than 10 years, it hasn’t introduced any serious syntax modifications that could make the code over-compiled. Recently, on 11th August 2020, it has released version 1.15. Let us see some amazing updates of Golang 1.1.5.

What’s New In Golang 1.15?

1. Compiler-
Package unsafe’s safety rules allow you to convert an unsafe.Pointer into uintptr when calling certain functions. Earlier, the compiler allowed different chained conversions. The compiler now requires precisely one conversion.
Golang 1,15 includes a -spectre to both compiler and assembler.
Now, the compiler rejects //go: compiler directives that does not have any meaning for the declaration they are applied to with “misplaced compiler directive” error.
Now, the compiler’s -json optimization logging reports large copies( >=128) and provides explanations of escape analysis decisions.

2. Linker-
Completely rewritten linker is the largest tooling change in 1.15. Have a look at the three major structural changes in new linker-

Moving from the linker to compiler, this enables parallelization as compiles are done in parallel across multiple CPUs, but the link step mostly be done in sequential at the end of the build. Also the results of the compiler are cached by Golang tooling.
Improving key data structures, primarily by avoiding strings. The recent linker makes use of large symbol table indexed by string; the new design avoids strings however 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 allocates less memory.

3. Tools-
Vet- Now, this tool warns about form string(x) conversions where x has integer type other than rune or byte. It also warns about type assertions from one interface type another interface type when the type assertion will always fail.
Go command- The GOPROXY environment supports skipping proxies that return errors. Now, Proxy URLs can be separated with commas or pipe characters. Various flag parsing issues in go test and go vet have been fixed.

4. Runtime-
For runtime, now allocation of small objects works more efficiently at high counts and has lower worst-case latency. Further, non-blocking receives on closed channels now perform and also non-blocking receives on open channels.

  1. Standard Library Additions- In every new version release, Go comes with various minor changes and updates to the library. Here we’re including some useful and significant changes-

tzdata Package-
A new embedded tzdata package was included that allows embedding the timezone database into a program. Importing this package allows the program to find timezone information without timezone database on local system. Also you can embed timezone database by building with -tags timet/zdata. This increases the size of the program by about 800 KB. This might be helpful and can test some code with the virtualized environments like Go playground.

X.509 CommonName Deprecation-
Older versions of Go use CommonName field on X.509 certificates as a hostname if there is no Subject Alternative Names, would be disabled by default. If Still need to use this legacy behavior, at that point you need to include x509ignoreCN=0 in the GODEBUG environment variable.

net/url Package-
The net/url package adds a new URL. The method redacted() returns the URL as a string. This is proposed in the Issue 34855. It is an extremely helpful improvement for audit logging and security. It’s a simple derivation from the URL.String() which masks the password if exists from the string being passed. It doesn’t modify at all to the URL itself yet a copy of it.

6. Minor Changes To The Library-
1. context-
While creating a derived context by using a nil parent is now disallowed.

2. bufio-
When a Scanner is used with an invalid io.Reader that incorrectly returns a negative number from Read, the Scanner will not panic, yet will rather restore the new error ErrBadReadCount.

3. crypto-
The PublicKey and PrivateKey types in the crypto/rsa, crypto/ecdsa and crypto/ed25519 packages now have an Equal method to to make type-safe interfaces for public keys or to compare keys for equivalence. The method signature is viable with go-cmp’s definition of equality. Now, Hash implements fmt.Stringer.

4. crypto/ecdsa-
New VerifyASN1 and SignASN1 functions allow generating and verifying ECDSA signatures in standard ASN.1 DER encoding.

5. crypto/elliptic-
New UnmarshalCompressed and MarshalCompressed functions allows encoding-decoding NIST elliptic curve points in compressed format.

6. crypto/rsa-
According to RFC 8017, now, VerifyPKCS1v15 rejects invalid short signatures with missing leading zeroes

Know more at- [https://solaceinfotech.com/blog/whats-new-in-golang-1-15/]

Top comments (0)