SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
Go

Go static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your GO code

  • All rules 94
  • Vulnerability21
  • Bug13
  • Security Hotspot14
  • Code Smell46
Filtered: 2 rules found
race-condition
    Impact
      Clean code attribute
        1. File existence checks followed by file creation should use atomic operations

           Vulnerability
        2. Busy waiting loops should use proper synchronization

           Bug

        Busy waiting loops should use proper synchronization

        intentionality - logical
        reliability
        maintainability
        Bug
        • concurrency
        • race-condition
        • memory-model
        • goroutine

        This rule raises an issue when a loop busy-waits for a variable to change without using proper synchronization mechanisms.

        Why is this an issue?

        How can I fix it?

        More Info

        Busy waiting for a variable to change without proper synchronization can cause serious problems in concurrent Go programs.

        When a goroutine uses a simple loop like for !done {} to wait for another goroutine to change a variable, there are no guarantees about memory visibility. The Go Memory Model specifies that without synchronization events, there’s no "happens-before" relationship between goroutines.

        This means:

        • The waiting goroutine may never observe the write to the variable, causing an infinite loop
        • Even if the variable change is observed, other related variable changes may not be visible
        • The program behavior becomes unpredictable and may vary between different runs or compiler optimizations

        The root cause is the absence of synchronization primitives. Simple variable reads and writes are not atomic operations that establish memory ordering between goroutines. Without explicit synchronization, the CPU and compiler are free to reorder operations in ways that break the intended logic.

        What is the potential impact?

        The program may hang indefinitely due to infinite loops, or exhibit unpredictable behavior due to data races. In production environments, this can lead to application freezes, resource exhaustion, and unreliable system behavior.

          Available In:
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories

        © 2025 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use