Using Go 1.24 Toolset
Installing and using Go 1.24 Toolset
Abstract
Providing feedback on Red Hat documentation Copy linkLink copied to clipboard!
We appreciate your feedback on our documentation. Let us know how we can improve it.
Submitting feedback through Jira (account required)
- Log in to the Jira website.
- Click Create in the top navigation bar
- Enter a descriptive title in the Summary field.
- Enter your suggestion for improvement in the Description field. Include links to the relevant parts of the documentation.
- Click Create at the bottom of the dialogue.
Chapter 1. Go Toolset Copy linkLink copied to clipboard!
Go Toolset is a Red Hat offering for developers on Red Hat Enterprise Linux (RHEL). It provides the Go programming language tools and libraries. Note that Go is alternatively known as golang.
Go Toolset is available as a module for RHEL 8 and as packages for RHEL 9 and 10.
1.1. Go Toolset components Copy linkLink copied to clipboard!
The following components are available as a part of Go Toolset:
| Name | Version | Description |
|---|---|---|
| golang | 1.24 | A Go compiler. |
| delve | 1.24 | A Go debugger. |
1.2. Go Toolset compatibility Copy linkLink copied to clipboard!
Go Toolset is available for Red Hat Enterprise Linux on the following architectures:
- AMD and Intel 64-bit (x86_64)
- 64-bit ARM (aarch64)
- IBM Power Systems, Little Endian (ppc64le)
- 64-bit IBM Z (s390x)
1.3. Installing Go Toolset Copy linkLink copied to clipboard!
Complete the following steps to install Go Toolset, including all dependent packages.
Prerequisites
- All available Red Hat Enterprise Linux updates are installed.
Procedure
Install Go Toolset:
On RHEL 8, enter:
yum module install go-toolset
# yum module install go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow On RHEL 9 and 10, enter:
dnf install go-toolset
# dnf install go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4. Installing Go documentation Copy linkLink copied to clipboard!
You can install documentation for the Go programming language on your local system.
Procedure
Install the
golang-docspackage:On RHEL 8, enter:
yum install golang-docs
# yum install golang-docsCopy to Clipboard Copied! Toggle word wrap Toggle overflow On RHEL 9 and 10, enter:
dnf install golang-docs
# dnf install golang-docsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
-
Open
/usr/lib/golang/doc/go_spec.htmlin a browser that is installed on the same host.
Chapter 2. The Go compiler Copy linkLink copied to clipboard!
2.1. Prerequisites Copy linkLink copied to clipboard!
2.2. Setting up a Go workspace Copy linkLink copied to clipboard!
Modern Go projects are built using modules. You can start with a single module and then optionally group multiple modules into a workspace to work on them simultaneously.
Procedure
Create a root directory for your projects, for example:
mkdir ~/go-projects/
$ mkdir ~/go-projects/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change into the project directory:
cd ~/go-projects/
$ cd ~/go-projects/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Initialize a module:
Create a directory for your module:
mkdir <module_name>
$ mkdir <module_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change into the module’s directory:
cd <module_name>
$ cd <module_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Initialize the module:
go mod init <module_name>
$ go mod init <module_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow This command creates a single-module project.
If you want to create multiple modules, repeat this step for every module.
If you want to work on multiple modules at the same time, create a multi-module workspace:
Change into the project directory:
cd ~/go-projects/
$ cd ~/go-projects/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Initialize a workspace to include multiple modules:
go work init <module_name_1> <module_name_n> ...
$ go work init <module_name_1> <module_name_n> ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3. Compiling a Go program Copy linkLink copied to clipboard!
You can compile your Go program using the Go compiler. The Go compiler creates an executable binary file as a result of compiling.
Prerequisites
- A Go workspace with configured modules.
Procedure
Compile the Go sources in the current directory:
go build .
$ go build .Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.4. Running a Go program Copy linkLink copied to clipboard!
The Go compiler creates an executable binary file as a result of compiling. Complete the following steps to run your program.
Procedure
Use one of the following options to execute your Go program:
To run an compiled program, enter:
./<file_name>
$ ./<file_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<file_name>with the name of your executable file.To compile the sources in the current directory and run the program in a single step, enter:
go run .
$ go run .Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.5. Installing compiled Go projects Copy linkLink copied to clipboard!
You can download and install third-party Go projects from online resources to use their executable files and libraries in further Go projects. After installation, the executable files and libraries of the project are copied according to the directories in the Go workspace. Its dependencies are installed as well.
Prerequisites
- A Go workspace with configured modules.
Procedure
Install a Go project:
go install <go_project>
$ go install <go_project>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.6. Downloading and installing Go projects Copy linkLink copied to clipboard!
You can download and install third-party Go projects from online resources to use their executable files and libraries in further Go projects. After installation, the executable files and libraries of the project are copied according to the directories in the Go workspace. Its dependencies are installed as well.
Prerequisites
- A Go workspace with configured modules.
Procedure
To download and install a Go project, enter:
go install <third_party_go_project>
$ go install <third_party_go_project>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: For information on possible values of third-party projects, enter:
go help importpath
$ go help importpathCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 3. The gofmt formatting tool Copy linkLink copied to clipboard!
Instead of a style guide, the Go programming language uses the gofmt code formatting tool. gofmt automatically formats your code according to the Go layout rules.
3.1. Prerequisites Copy linkLink copied to clipboard!
3.2. Formatting code Copy linkLink copied to clipboard!
You can use the gofmt formatting tool to format code in a given path. When the path leads to a single file, the changes apply only to the file. When the path leads to a directory, all .go files in the directory are processed.
Procedure
To format your code in a given path, enter:
gofmt -w <code_path>
$ gofmt -w <code_path>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<code_path>with the path to the code you want to format.NoteTo print the formatted code to standard output instead of writing it to the original file, omit the
-woption.
3.3. Previewing changes to code Copy linkLink copied to clipboard!
You can use the gofmt formatting tool to preview changes done by formatting code in a given path. The output in unified diff format is printed to standard output.
Procedure
Show differences in your code in a given path:
gofmt -d <code_path>
$ gofmt -d <code_path>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<code_path>with the path to the code you want to compare.
3.4. Simplifying code Copy linkLink copied to clipboard!
You can use the gofmt formatting tool to simplify your code.
Procedure
To simplify code in a given path, enter:
gofmt -s -w <code_path>
$ gofmt -s -w <code_path>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<code_path>with the path to the code you want to simplify.To apply the changes, enter:
gofmt -w <code_path>
$ gofmt -w <code_path>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<code_path>with the path to the code you want to format.
3.5. Refactoring code Copy linkLink copied to clipboard!
You can use the gofmt formatting tool to refactor your code by applying arbitrary substitutions.
Procedure
To refactor your code in a given path, enter:
gofmt -r -w <rewrite_rule> <code_path>
$ gofmt -r -w <rewrite_rule> <code_path>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<code_path>with the path to the code you want to refactor and<rewrite_rule>with the rule you want it to be rewritten by.To apply the changes, enter:
gofmt -w <code_path>
# gofmt -w <code_path>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<code_path>with the path to the code you want to format.
Chapter 4. The Go race detector Copy linkLink copied to clipboard!
Go Toolset includes the Go race detector, which is a tool of the Go standard library for finding race conditions. Note that the race detector has a significant runtime resource overhead.
4.1. Prerequisites Copy linkLink copied to clipboard!
4.2. Using the Go race detector Copy linkLink copied to clipboard!
Use the Go race detector to check your code for race conditions.
Procedure
Use the race detector:
go build -race -o <output_file> <go_main_package>
# go build -race -o <output_file> <go_main_package>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<output_file>with the name of your executable file and<go_main_package>with the name of the package you want to test.
Chapter 5. Container images with Go Toolset Copy linkLink copied to clipboard!
You can build your own Go Toolset containers from either Red Hat Enterprise Linux container images or Red Hat Universal Base Images (UBI).
5.1. Red Hat Enterprise Linux Go Toolset container images contents Copy linkLink copied to clipboard!
The Red Hat Enterprise Linux container images of Go Toolset contain the following packages:
| Component | Version | Package |
|---|---|---|
|
| 1.24 | go-toolset-1.24 |
5.2. Pulling the RHEL-based Go Toolset container image Copy linkLink copied to clipboard!
Pull the container image from the Red Hat registry before running your container and performing actions.
Procedure
Pull the required image:
For an image based on RHEL 8, enter:
podman pull registry.redhat.io/rhel8/go-toolset
# podman pull registry.redhat.io/rhel8/go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow For an image based on RHEL 9, enter:
podman pull registry.redhat.io/rhel9/go-toolset
# podman pull registry.redhat.io/rhel9/go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow For an image based on RHEL 10, enter:
podman pull registry.redhat.io/rhel10/go-toolset
# podman pull registry.redhat.io/rhel10/go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.3. Pulling the UBI-based Go Toolset container image Copy linkLink copied to clipboard!
Pull the container image from the Red Hat registry before running your container and performing actions.
Procedure
Pull the required image:
For an image based on RHEL 8, enter:
podman pull registry.access.redhat.com/ubi8/go-toolset
# podman pull registry.access.redhat.com/ubi8/go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow For an image based on RHEL 9, enter:
podman pull registry.access.redhat.com/ubi9/go-toolset
# podman pull registry.access.redhat.com/ubi9/go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow For an image based on RHEL 10, enter:
podman pull registry.access.redhat.com/ubi10/go-toolset
# podman pull registry.access.redhat.com/ubi10/go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.4. Creating a custom UBI-based container with Go Toolset Copy linkLink copied to clipboard!
Go Toolset packages are part of the Red Hat Universal Base Images (UBIs) repositories, which means you can install Go Toolset as an addition to the base UBI container image. To keep the container image size small, install only individual packages instead of the entire Go Toolset.
Alternatively, you can install the UBI Go Toolset container image to access Go Toolset. For further information, see Pulling the UBI-based Go Toolset container image.
Prerequisites
- An existing container file. For information on creating Containerfiles, see the Dockerfile reference page.
Procedure
To create a container image containing Go Toolset, add the following to your container file:
For an image based on RHEL 8, enter:
FROM registry.access.redhat.com/ubi8/ubi:latest RUN yum module install -y go-toolset
FROM registry.access.redhat.com/ubi8/ubi:latest RUN yum module install -y go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow For an image based on RHEL 9, enter:
FROM registry.access.redhat.com/ubi9/ubi:latest RUN yum install -y go-toolset
FROM registry.access.redhat.com/ubi9/ubi:latest RUN yum install -y go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow For an image based on RHEL 10, enter:
FROM registry.access.redhat.com/ubi10/ubi:latest RUN yum install -y go-toolset
FROM registry.access.redhat.com/ubi10/ubi:latest RUN yum install -y go-toolsetCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 6. Changes in Go Toolset 1.24 Copy linkLink copied to clipboard!
Go Toolset has been updated to version 1.24.4 with the release of the RHSA-2025:10677 advisory.
Language:
- Generic type aliases are now fully supported, allowing type aliases to be parameterized for increased flexibility with generics.
Tools:
-
The Go module system supports
tooldirectives ingo.modfiles, enabling direct management of executable dependencies. -
The
go build,go install, andgo testcommands now support the-jsonflag for structured output. -
The new
GOAUTHenvironment variable provides enhanced authentication for private modules.
-
The Go module system supports
Runtime and Performance:
- Runtime improvements reduce CPU overhead by 2–3% on average.
- Notable changes include a new map implementation based on Swiss Tables and more efficient memory allocation.
Standard Library:
-
The new
os.Roottype enables directory-limited filesystem access. -
The
testing.B.Loopmethod improves benchmarking. -
The
runtime.AddCleanupfunction provides a more flexible finalization mechanism. -
The new
weakpackage introduces weak pointers.
-
The new
Cryptography:
-
New packages for ML-KEM post-quantum key exchange (
crypto/mlkem), HKDF, PBKDF2, and SHA-3 are now available. - The Go Cryptographic Module is now under review for FIPS 140-3 certification.
-
New packages for ML-KEM post-quantum key exchange (
Additional updates:
-
The
vettool includes a new analyzer for detecting common mistakes in tests and examples. - The objdump tool now supports more architectures.
-
Cgointroduces annotations for improved performance and correctness.
-
The
For more information, see the upstream release notes.
Go Toolset is a rolling Application Stream, and Red Hat supports only the latest version. For more information, see the Red Hat Enterprise Linux Application Streams Life Cycle document.