What's New in Golang 1.20

Author

Reads 1.1K

From above of crop anonymous person in stylish wear and shiny sneakers demonstrating takeaway glass of hot drink with logotype
Credit: pexels.com, From above of crop anonymous person in stylish wear and shiny sneakers demonstrating takeaway glass of hot drink with logotype

Golang 1.20 has just been released, and it's packed with exciting new features. The Go team has been working hard to improve the language and make it even more efficient.

One of the biggest changes in Golang 1.20 is the introduction of the experimental "Nebulon" garbage collector. This new collector is designed to improve performance and reduce latency in certain workloads.

The Nebulon garbage collector is still experimental, but it has already shown promising results in early testing. It's great to see the Go team pushing the boundaries of what's possible with the language.

Go 1.20 also includes several other notable changes, including improved support for concurrency and better error handling. These changes will make it easier for developers to write efficient and scalable code.

Language Changes

Go 1.20 introduces several changes to the language that simplify generic code and improve overall functionality. One notable change is the satisfaction of the predeclared comparable constraint by ordinary comparable types, such as interfaces.

You might like: Golang Comparable

A Programmer Working From Home
Credit: pexels.com, A Programmer Working From Home

This simplification makes it easier to write generic code that can work with various types. For example, you can now use interfaces as type arguments in generic functions.

The language specification also clarifies the order in which array elements and struct fields are compared, which affects what happens in case of panics during comparisons.

Here are the new functions added to the unsafe package:

  • SliceData
  • String
  • StringData

These functions provide the complete ability to construct and deconstruct slice and string values, without depending on their exact representation.

Mime/Multipart

In Go 1.19.8 and later, the mime/multipart package has some new limits in place to protect against malicious inputs.

The number of headers in a part is limited to 10000, and this can be adjusted with the GODEBUG=multipartmaxheaders setting.

Reader.NextPart and Reader.NextRawPart have been updated to enforce this limit.

Reader.ReadForm also has a limit of 1000 parts in a form, which can be adjusted with the GODEBUG=multipartmaxparts setting.

The HTTP server now accepts HEAD requests containing a body, which is a change from previous versions.

This means developers can now send HEAD requests with a body, rather than having to send them without.

Net/http

Close Up Photo of Cables Plugged into the Server
Credit: pexels.com, Close Up Photo of Cables Plugged into the Server

The net/http package has seen some great improvements. The ResponseWriter.WriteHeader function now supports sending 1xx status codes.

This means you can use these status codes in your HTTP responses, which is useful for certain scenarios.

Leading and trailing spaces are now trimmed from cookie names, so a cookie setting of “name =value” is accepted as setting the cookie “name”.

Fmt

The Fmt section of the language changes is quite exciting. The Errorf function now supports multiple occurrences of the %w format verb, which returns an error that unwraps to the list of all arguments to %w.

This is a game-changer for error handling in your code. The new FormatString function recovers the formatting directive corresponding to a State, which can be useful in Formatter implementations.

Unicode/Utf16

Language changes are an exciting and sometimes challenging aspect of programming. The new AppendRune function in unicode/utf16 appends the UTF-16 encoding of a given rune to a uint16 slice.

Credit: youtube.com, Understanding Unicode, UTF-8, and UTF-16

This is analogous to utf8.AppendRune, which does the same thing but for UTF-8 encoding. The new function is a useful addition to the unicode/utf16 package.

The function is designed to work seamlessly with uint16 slices, making it a great choice for developers working with UTF-16 encoded data. It's a simple and efficient way to append UTF-16 encoded runes to a slice.

This change will likely be useful for developers who need to work with UTF-16 encoded data in their projects. The new function will save them time and effort by providing a straightforward way to append UTF-16 encoded runes.

Suggestion: Golang Append

Tool Improvements

The tool improvements in Go 1.20 are a significant step forward. The cover tool can now collect coverage profiles of whole programs, not just unit tests.

One of the most notable changes is the way the go tool handles standard library package archives. Previously, these archives were pre-compiled and shipped with the distribution, but now they're built as needed and cached in the build cache.

For your interest: Golang Go

Credit: youtube.com, Профилирование Go приложений - Антон Кучеров, soax.com

The go test -json command has been improved to be more robust in the presence of stray writes to stdout. This means you can rely on it to produce accurate results even in tricky situations.

The go build, go install, and other build-related commands now accept a -pgo flag for profile-guided optimizations and a -cover flag for whole-program coverage analysis.

Here are the new flags and their purposes:

  • -pgo: enables profile-guided optimizations
  • -cover: enables whole-program coverage analysis

The vet tool now reports more loop variable reference mistakes that may occur in tests running in parallel. This helps catch errors before they become a problem.

Standard Library Additions

In Go 1.20, the standard library has been enriched with some exciting additions. The crypto/ecdh package now provides explicit support for Elliptic Curve Diffie-Hellman key exchanges over NIST curves and Curve25519.

A new function called errors.Join returns an error wrapping a list of errors that can be obtained again if the error type implements the Unwrap() []error method. This is a game-changer for developers who need to handle multiple errors in a single function.

Credit: youtube.com, Go (Golang) Tutorial #6 - The Standard Library

The http.ResponseController type provides access to extended per-request functionality not handled by the http.ResponseWriter interface. This is particularly useful for developers who need to implement custom error handling or logging mechanisms.

Here are some key additions to the standard library in Go 1.20:

  • crypto/ecdh package for Elliptic Curve Diffie-Hellman key exchanges
  • errors.Join function for wrapping and unwrapping errors
  • http.ResponseController type for extended per-request functionality
  • context.WithCancelCause function for canceling contexts with a given error
  • os/exec.Cmd fields Cancel and WaitDelay for specifying behavior on context cancellation or process exit

Path/FilePath

The Path/FilePath library is a game-changer for file system navigation.

The new IsLocal function is a great addition, allowing you to check if a path is lexically local to a directory.

This means you can use it to determine if a file is within the current directory's subtree.

For example, if IsLocal(p) returns True, then Open(p) will indeed refer to a file within the current directory.

This can save you from having to manually check the file's location, which can be a real time-saver.

Encoding/Binary

In the Encoding/Binary section, you'll notice a change in how the ReadVarint and ReadUvarint functions handle partial values. They now return io.ErrUnexpectedEOF after reading a partial value, rather than io.EOF.

Credit: youtube.com, Go Standard Library Solutions: Encoding

This change is a significant improvement, as it helps prevent unexpected errors when working with variable-length integers. It's a subtle but important tweak that can save you from headaches down the line.

The ReadVarint and ReadUvarint functions are designed to handle variable-length integers, which can be a bit tricky to work with. Now, they'll give you a clear indication when something goes awry, making it easier to write robust code.

Check this out: Golang Length of String

Types

The new Satisfies function reports whether a type satisfies a constraint.

This change is significant because it aligns with the new language semantics that distinguish satisfying a constraint from implementing an interface.

The Satisfies function is a key addition to the go/types package, making it easier to determine if a type meets a specific requirement.

This distinction is crucial for developers who need to ensure their code adheres to specific constraints and interfaces.

Developers can now use the Satisfies function to write more robust and reliable code by checking if a type satisfies a given constraint.

This new functionality will undoubtedly improve code quality and reduce errors caused by incorrect interface implementations.

Math/Rand

Credit: youtube.com, Go Standard Library Solutions : Let's Do Some Math | packtpub.com

The math/rand package has undergone some changes that are worth noting. The global random number generator is now automatically seeded with a random value.

Programs that rely on a reproducible sequence of random numbers should use rand.New(rand.NewSource(seed)) to allocate their own random source. This ensures a consistent sequence of numbers.

Setting GODEBUG=randautoseed=0 in the environment will restore the earlier consistent global seeding behavior. This can be useful for programs that require a specific sequence of numbers.

Methods of the Reader type now handle errors returned by the underlying io.Reader. This means that errors will be wrapped and made available for use in programs.

For another approach, see: Golang Errors

Solution: Date and Time Only Constants

In Go 1.20, DateOnly and TimeOnly constants were introduced as a simple solution to handle date and time separately.

This feature is useful when you need to print date and time in a specific format. For example, you can print the current date and time using these constants.

Recommended read: Golang Time since

Detailed close-up of a Nixon watch dial showcasing time and date with a sleek blue face.
Credit: pexels.com, Detailed close-up of a Nixon watch dial showcasing time and date with a sleek blue face.

With DateOnly and TimeOnly constants, you can easily separate date and time operations and make your code more organized and efficient.

In a loop, you can use these constants to print the current date and time on each iteration, making it easier to track and debug your code.

This feature is particularly useful when you have functions that can return multiple errors, and you need to check each error separately to see if it's related to a closed file or not.

Performance and Runtime

Go 1.20 brings several performance and runtime improvements. The compiler and garbage collector have been optimized to reduce memory overhead and improve CPU performance by up to 2%.

Build times have also seen significant improvements, with compilation times reduced by up to 10%. This brings build speeds back in line with Go 1.17.

The garbage collector's internal data structures have been reorganized to be more space and CPU efficient, reducing memory overheads and improving overall CPU performance by up to 2%. This change also makes the garbage collector behave less erratically with respect to goroutine assists in some circumstances.

Some additional runtime improvements include a new runtime/coverage package for writing coverage profile data at runtime from long-running and/or server programs, and the garbage collector's background sweeper now yields less frequently, resulting in many fewer extraneous events in execution traces.

Suggestion: Golang Runtime

Runtime/pprof

Credit: youtube.com, Go Profiling Tutorial: Find Performance Bottlenecks with pprof (Complete Guide 2025)

The runtime/pprof tool has gotten some exciting updates. Mutex profile samples are now pre-scaled, which means old mutex profile samples won't be scaled incorrectly if the sampling rate changes during execution.

This is a big improvement, especially for those who rely on accurate profiling data. Profiles collected on Windows now include memory mapping information, which fixes symbolization issues for position-independent binaries.

This change is particularly useful for developers working on Windows, as it makes it easier to debug and optimize their code.

Runtime/Trace

The garbage collector's background sweeper now yields less frequently, resulting in many fewer extraneous events in execution traces. This improvement should make it easier to get accurate and useful information from runtime traces.

Some of the garbage collector's internal data structures were reorganized to be both more space and CPU efficient, reducing memory overheads and improving overall CPU performance by up to 2%. This change should make a noticeable difference in the performance of long-running programs.

Take a look at this: Golang Performance

Runtime

Credit: youtube.com, 4 Runtime Performance Optimizations

The runtime performance in Go 1.20 has seen some significant improvements. The garbage collector's internal data structures have been reorganized to be more space and CPU efficient, which reduces memory overheads and improves overall CPU performance by up to 2%.

This change also makes the garbage collector behave less erratically with respect to goroutine assists in some circumstances. The garbage collector's background sweeper now yields less frequently, resulting in many fewer extraneous events in execution traces.

Here are some key runtime improvements in Go 1.20:

  • The garbage collector's internal data structures have been reorganized to be more space and CPU efficient.
  • The garbage collector behaves less erratically with respect to goroutine assists in some circumstances.
  • The garbage collector's background sweeper now yields less frequently.
  • Profiles collected on Windows now include memory mapping information.

These changes will help improve the overall performance and stability of Go 1.20.

Solution 3: Memory Arenas

Memory arenas are a concept that allows you to set a number of objects to a continuous range of memory in the heap, making it easier to deallocate all in one manual call.

To use this feature, you need to add the environment variable GOEXPERIMENT=arenas when running your program.

This feature is experimental and should be used with extra care, not in production as it may only improve performance in very specific use cases.

If this caught your attention, see: Golang Memory Management

Context

Credit: youtube.com, Runtime vs. Compile Time: Understanding the Differences

Context plays a crucial role in performance and runtime. The new WithCancelCause function provides a way to cancel a context with a given error. This error can be retrieved by calling the new Cause function.

Having a way to cancel a context with an error is super useful, especially when dealing with complex operations that need to be interrupted. The WithCancelCause function makes this possible.

Understanding how to work with contexts and errors is essential for writing efficient code. The new Cause function allows you to retrieve the error that caused a context to be canceled.

Security and Crypto

In Go 1.20, security improvements have been made to the archive/tar and archive/zip packages. The GODEBUG environment variable can now be used to enforce more secure paths in archives.

A malicious tar file with an absolute path or invalid characters will now be detected and prevented from overriding local files. For example, if you create a malicious tar file with a path like ../../../../LICENSE, it will be detected and prevented from being extracted.

For your interest: Golang Write String to File

Credit: youtube.com, Golang and Cryptography: Part 1

The crypto/rsa package has also seen significant changes, including a new field OAEPOptions.MGFHash to configure the MGF1 hash separately for OAEP decryption. This new field allows for more secure and customizable decryption operations.

The crypto/rsa package now uses a safer, constant-time backend, but this comes with a performance cost - decryption operations are now approximately 15-45% slower, depending on the architecture. However, encryption operations are still 5-10x faster than decryption.

Archive Security Improvements

The Go team has made significant improvements to archive security in recent updates.

Two new environment variables, GODEBUG=tarinsecurepath=0 and GODEBUG=zipinsecurepath=0, have been introduced to enforce security improvements for archive/tar and archive/zip respectively.

These environment variables will now return an error, ErrInsecurePath, for entries with absolute paths, invalid characters, or reserved names, preventing malicious files from being extracted.

The new security improvements are designed to prevent bad actors from including malicious files that could override local ones when untaring or unzipping.

Close-up of colorful source code on a monitor, showcasing programming and technology concepts.
Credit: pexels.com, Close-up of colorful source code on a monitor, showcasing programming and technology concepts.

For example, a malicious tar file created with the command "tar -cvf example.tar example ../../../../LICENSE" will be detected if the GODEBUG=tarinsecurepath=0 environment variable is set.

Similarly, a malicious zip file will be detected if the GODEBUG=zipinsecurepath=0 environment variable is set.

In the future, the Go team may enable these security improvements by default, making it even harder for malicious files to be extracted.

The new security improvements bring a sense of relief to developers who use Go for their projects, knowing that their archives are now more secure than ever.

Intriguing read: Golang Set Env Variable

Crypto/Rsa

The new field OAEPOptions.MGFHash allows configuring the MGF1 hash separately for OAEP decryption.

RSA decryption operations now have a CPU runtime increase of approximately 15% on amd64 and 45% on arm64, and more on 32-bit architectures.

Encryption operations are now approximately 20x slower than before, but still 5-10x faster than decryption.

The crypto/rsa module now uses a new, safer, constant-time backend, which is expected to improve in future releases.

Programs must not modify or manually generate the fields of PrecomputedValues, as this can cause issues.

Crypto/TLS

Credit: youtube.com, SSL/TLS Explained in 7 Minutes

In the realm of crypto/TLS, a significant improvement has been made to the way certificates are handled. Parsed certificates are now shared across all clients actively using that certificate.

This change can lead to significant memory savings in programs that make many concurrent connections to a server or collection of servers sharing any part of their certificate chains.

Handshake failures due to certificate verification failures now return an error of the new type CertificateVerificationError, which includes the presented certificates. This error provides more detailed information about the failure, making it easier to diagnose and fix issues.

See what others are reading: Golang Create Error

Compiler and Runtime

Go 1.20 has made significant improvements to the compiler and runtime, making it a worthwhile upgrade for developers.

The garbage collector's internal data structures have been reorganized to be more space and CPU efficient, resulting in a memory overhead reduction and a 2% improvement in overall CPU performance.

Go 1.20 adds preview support for profile-guided optimization (PGO), which enables the toolchain to perform application- and workload-specific optimizations based on run-time profile information.

Credit: youtube.com, Building Go Executables: Race Detector Runtime Overheads

Enabling PGO improves performance by about 3-4% and is now supported in the compiler, allowing developers to pass the path of a pprof profile file via the -pgo flag to gobuild.

The Go 1.20 compiler has also upgraded its front-end to use a new way of handling the compiler's internal data, fixing generic-types issues and enabling type declarations within generic functions and methods.

Anonymous interface cycles are now rejected by default, which has always had subtle correctness issues, and the language specification is planned to be updated in Go 1.22 to formally disallow them.

Go 1.20 improves build speeds by up to 10%, bringing it back in line with Go 1.17, and relative to Go 1.19, generated code performance is generally slightly improved.

The addition of generics in Go 1.18 led to longer run times and compile times, but Go 1.20 has made significant improvements to address these issues.

You might enjoy: Golang Generic Struct

Error Handling

Error handling in Go 1.20 has seen significant improvements. Go 1.20 expands support for error wrapping to permit an error to wrap multiple other errors.

Credit: youtube.com, The secret to making Golang error handling a breeze

An error e can wrap more than one error by providing an Unwrap method that returns a []error. The errors.Is and errors.As functions have been updated to inspect multiply wrapped errors.

The fmt.Errorf function now supports multiple occurrences of the %w format verb, which will cause it to return an error that wraps all of those error operands. This change makes it easier to handle multiple errors in a single function call.

The new function errors.Join returns an error wrapping a list of errors. Here's a quick rundown of how it works:

  • errors.Join(ErrOne, ErrTwo) returns an error that wraps ErrOne and ErrTwo.
  • errors.Is and errors.As functions can inspect multiply wrapped errors.

This expands the changes that were introduced in Go 1.13, allowing wrapping multiple errors using both the %w verb and the Join function.

Improved Detection of Loop Variable Capture

The vet tool now reports references to loop variables following a call to T.Parallel() within subtest function bodies.

This improvement is crucial because such references may observe the value of the variable from a different iteration, typically causing test cases to be skipped.

The tool also detects reference mistakes in more places, not just the last statement of the loop body as it previously did.

Now, it recursively inspects the last statements within if, switch, and select statements, making it more thorough in its analysis.

Suggestion: Golang for Loops

Code Coverage for Running Apps

Focused view of programming code displayed on a laptop, ideal for tech and coding themes.
Credit: pexels.com, Focused view of programming code displayed on a laptop, ideal for tech and coding themes.

Code coverage for running apps is a game-changer for error handling. It allows you to generate code coverage profiles not only from unit tests but also from running applications. This means you can identify areas of your code that are not being executed, which can help you catch errors and improve your overall code quality.

The go build, go install, and other build-related commands now support a -cover flag that builds the specified target with code coverage instrumentation. This flag enables you to generate code coverage profiles for running applications.

To use this feature, you can run your application with the GOCOVERDIR variable set to a directory where the code coverage profile will be saved. For example, you can use cover/:

A simple example of code that will never be executed is true == false. You can use the -cover flag to generate a code coverage profile for this application, which can then be visualized in an HTML page.

Wrapping Multiple Errors

Credit: youtube.com, Learn Golang Error Handling from errors package

Wrapping Multiple Errors is a powerful feature in Go 1.20 that allows an error to wrap multiple other errors. This is achieved by providing an Unwrap method that returns a []error.

The errors.Is and errors.As functions have been updated to inspect multiply wrapped errors, making it easier to detect and handle multiple errors.

The fmt.Errorf function now supports multiple occurrences of the %w format verb, which will cause it to return an error that wraps all of those error operands.

The new function errors.Join returns an error wrapping a list of errors, similar to using the %w verb.

Here's an example of how to use errors.Join to wrap multiple errors:

  • L14: uses the new errors.Join function to wrap multiple errors, it joins ErrOne and ErrTwo and returns only one.
  • L17-L23: demonstrate that using errors.Is supports multiple errors, therefore it allows to detect either ErrOne or ErrTwo
  • L26: uses the verb %w to wrap multiple errors, similar behavior to errors.Join, it returns only one, and
  • L30-32: like we did before errors.Is works as well.

New Method WithCancelCause

Context's new method WithCancelCause is a game-changer for error handling. It allows you to cancel a context with a given error, which can be retrieved by calling the new Cause function.

The WithCancelCause function is an improvement over the existing WithCancel function. WithCancelCause lets you cancel a context by calling the returned function with an explicit error.

Credit: youtube.com, Error handling in Go - Vitaliy Popov

Using context.Cause is key to determining the cause of the cancellation. This function will tell you whether the cancellation came from WithCancel or WithCancelCause, and therefore whether the cause was context.Canceled or a custom error.

You can see the difference in action by comparing the code for WithCancel and WithCancelCause. The WithCancelCause code includes the call to context.Cause, which is what makes it so powerful.

Addressing Current Pitfalls with New Features

Go 1.20's error handling features address several common pitfalls, making it easier to handle errors in a more robust way.

One of the main issues with error handling in Go is that it's often difficult to unwrap multiple errors from a single error. However, Go 1.20's new error wrapping feature allows an error to wrap multiple other errors.

The fmt.Errorf function now supports multiple occurrences of the %w format verb, making it easy to create errors that wrap multiple other errors.

Aerial view of people playing Go outdoors, showcasing a casual game setup on a grassy lawn.
Credit: pexels.com, Aerial view of people playing Go outdoors, showcasing a casual game setup on a grassy lawn.

The errors.Join function returns an error wrapping a list of errors, providing a convenient way to combine multiple errors into a single error.

In addition to improving error handling, Go 1.20 also addresses issues with tooling and performance.

The cover tool now collects coverage profiles of whole programs, not just unit tests. This makes it easier to get a comprehensive view of code coverage.

The go build, go install, and other build-related commands now accept a -pgo flag enabling profile-guided optimizations as well as a -cover flag for whole-program coverage analysis.

By using these new features, developers can avoid common pitfalls and write more robust and efficient code.

New Features and Improvements

Go 1.20 brings a slew of exciting improvements to the table. One of the most notable changes is the enhanced tooling, which now allows for whole-program coverage profiles, rather than just unit tests.

The go tool no longer relies on pre-compiled standard library package archives, resulting in smaller downloads. Instead, packages in the standard library are built as needed and cached in the build cache, just like other packages.

Credit: youtube.com, Golang 1.20: What is new?

The go build, go install, and other build-related commands now accept a -pgo flag for profile-guided optimizations and a -cover flag for whole-program coverage analysis. This is a significant improvement, as it allows for more precise and efficient builds.

The vet tool reports more loop variable reference mistakes that may occur in tests running in parallel. This is a great addition, as it helps catch errors before they cause problems.

Here are some key tool improvements in Go 1.20:

  • Whole-program coverage profiles
  • Smaller downloads due to caching of packages in the build cache
  • -pgo flag for profile-guided optimizations
  • -cover flag for whole-program coverage analysis
  • Improved vet tool for catching loop variable reference mistakes

Go 1.20 also boasts improved performance, with compiler and garbage collector improvements reducing memory overhead and improving CPU performance by up to 2%. This is a significant boost, especially for large-scale applications.

Build times have also seen a notable improvement, with up to 10% faster compilation times. This brings build speeds back in line with Go 1.17.

Context's new method WithCancelCause provides a way to cancel a context with a given error. This is an improvement over the existing WithCancel function, which allows for more flexibility and control.

Operating System and Architecture

Credit: youtube.com, Can I Build an Operating System in Go?

Go 1.20 introduces experimental support for FreeBSD on RISC-V, allowing developers to compile Go programs for this specific architecture.

FreeBSD on RISC-V is now a supported configuration, with the ability to compile Go programs using the GOOS=freebsd and GOARCH=riscv64 flags.

This new support opens up possibilities for developers working with this unique combination of operating system and architecture.

Os/Exec

Os/Exec is a crucial part of any operating system, allowing you to run external commands and interact with the system in meaningful ways.

The os/exec package in Go provides a way to execute external commands and capture their output. It's a powerful tool for automating tasks and building more complex systems.

The new Cmd fields Cancel and WaitDelay specify the behavior of the Cmd when its associated Context is canceled or its process exits with I/O pipes still held open by a child process.

Freebsd/Risc-V

FreeBSD/Risc-V is a powerful combination that's gaining traction. Go 1.20 has added experimental support for FreeBSD on RISC-V, specifically with the flags GOOS=freebsd and GOARCH=riscv64.

Credit: youtube.com, Tues1445 - FreeBSD and RISC-V - Ruslan Bukin, University of Cambridge

This means developers can now experiment with running Go programs on RISC-V architecture with FreeBSD as the operating system. The possibilities are endless, from optimizing performance to exploring new use cases.

RISC-V is an open-source instruction set architecture that's designed to be flexible and customizable, making it a great match for FreeBSD's community-driven approach.

Version

The goversion-m command now supports reading more types of Go binaries, most notably, Windows DLLs built with gobuild-buildmode=c-shared and Linux binaries without execute permission.

This is a significant improvement for developers working with Go, as it allows for more flexibility when building and reading binaries.

Windows DLLs built with gobuild-buildmode=c-shared can now be easily read by the goversion-m command, making it easier to manage and maintain Go projects that rely on shared libraries.

For Linux binaries, the lack of execute permission is no longer a barrier, enabling developers to work with these files in a more streamlined way.

This enhancement is a testament to the ongoing development and refinement of the Go toolchain, making it an even more powerful and versatile platform for building software.

Expand your knowledge: C Golang

Crypto and Security

Security Logo
Credit: pexels.com, Security Logo

In Go 1.20, security improvements have been made to archive/tar and archive/zip formats. The GODEBUG environment variable can now be used to enforce secure path checking.

The archive/tar format now returns an error for an entry with an absolute path, invalid characters, or a reserved name on Windows. This prevents malicious files from overriding local ones when untaring.

Similarly, archive/zip now returns an error when opening an archive with an absolute path, invalid characters, or a reserved name on Windows. This new security improvement aims to prevent bad actors from including malicious files in archives.

The Go team may disable insecure paths by default in future releases, so it's a good idea to get familiar with the GODEBUG environment variables.

Crypto/Ed25519

The PrivateKey.Sign method and VerifyWithOptions function now support signing pre-hashed messages with Ed25519ph, indicated by an Options.HashFunc that returns crypto.SHA512.

This is a significant improvement, allowing for more flexibility and security in message signing.

Credit: youtube.com, Ed25519 Vs ECDSA? - SecurityFirstCorp.com

Ed25519ph is a type of Ed25519 signature that uses a pre-hashed message, which can be more efficient and secure in certain scenarios.

The Options.HashFunc field is now used to specify the hash function to be used, in this case, crypto.SHA512.

The new Options.Context field can also be set to support Ed25519ctx and Ed25519ph with context.

This addition enables developers to use context-aware signatures, which can be useful in certain applications.

Crypto/X509

In the world of crypto/x509, you can now parse and marshal keys of type *crypto/ecdh.PrivateKey using ParsePKCS8PrivateKey and MarshalPKCS8PrivateKey.

These functions were previously limited to parsing and marshaling keys of type *ecdsa.PrivateKey.

ParsePKCS8PrivateKey and MarshalPKCS8PrivateKey now support keys of type *crypto/ecdh.PrivateKey.

This is a great addition, as it allows for more flexibility when working with keys.

Parsing NIST curve keys still returns values of type *ecdsa.PublicKey and *ecdsa.PrivateKey.

You'll need to use the new ECDH methods to convert these keys to the crypto/ecdh types.

The crypto/x509 package has been updated to support keys of type *crypto/ecdh.PublicKey using ParsePKIXPublicKey and MarshalPKIXPublicKey.

This is a significant improvement, making it easier to work with public keys.

Frequently Asked Questions

Is Netflix using Golang?

Yes, Netflix is utilizing Go (Golang) for building internal tools. They leverage Go for high-performance systems, including Chaos Monkey, which tests the resilience of their infrastructure.

Thomas Goodwin

Lead Writer

Thomas Goodwin is a seasoned writer with a passion for exploring the intersection of technology and business. With a keen eye for detail and a knack for simplifying complex concepts, he has established himself as a trusted voice in the tech industry. Thomas's writing portfolio spans a range of topics, including Azure Virtual Desktop and Cloud Computing Costs.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.