Este contenido no está disponible en el idioma seleccionado.

Chapter 4. The Go race detector


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

4.2. Using the Go race detector

Use the Go race detector to check your code for race conditions.

Procedure

To use the race detector, run:

  • On Red Hat Enterprise Linux 7:

    $ scl enable go-toolset-1.18 'go build -race -o <output_file> <go_main_package>'
    Copy to Clipboard Toggle word wrap
    • Replace <output_file> with the name of your executable file and <go_main_package> with the name of the package you want to test.
  • On Red Hat Enterprise Linux 8:

    $ go build -race -o <output_file> <go_main_package>
    Copy to Clipboard Toggle word wrap
    • Replace <output_file> with the name of your executable file and <go_main_package> with the name of the package you want to test.
  • On Red Hat Enterprise Linux 9:

    $ go build -race -o <output_file> <go_main_package>
    Copy to Clipboard Toggle word wrap
    • Replace <output_file> with the name of your executable file and <go_main_package> with the name of the package you want to test.
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat