Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Metadata
ID:go-best-practices/do-not-compare-nan
Language: Go
Severity: Notice
Category: Best Practices
Description
You do not need to convert the string into a slice of bytes to use Write, you can just use the string directly.
Non-Compliant Code Examples
packagemainimport("fmt""math")funcmain(){n:=5.0aNaN:=math.NaN()// This case cannot be caught with current capabilities
ifn==aNaN{fmt.Println("hello")}elseifn>math.NaN(){fmt.Println("hi")}fmt.Println("goodbye")}
Seamless integrations. Try Datadog Code Analysis
Datadog Code Analysis
Try this rule and analyze your code with Datadog Code Analysis
How to use this rule
1
2
rulesets:- go-best-practices # Rules to enforce Go best practices.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Analysis scans to your CI pipelines