-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Closed
Copy link
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.RefactoringIssues related to refactoring toolsIssues related to refactoring toolsgopls/analysisIssues related to running analysis in goplsIssues related to running analysis in gopls
Milestone
Description
(Splitting out of #70815 (comment) on behalf of @spencerschrock.)
Currently at HEAD (44b61a1d174cc06329b20f5de60c2b0c800741a4):
main.go:7:5: if/else statement can be modernized using max
package main
import "fmt"
func main() {
var x, y int
if x <= 0 { // a value of -1 or 0 will use a default value (30)
y = 30
} else {
y = x
}
fmt.Print(y)
}
Applying the suggested fix doesn't yield an equivalent result:
package main
import "fmt"
func main() {
var x, y int
y = max(x, 0)
fmt.Print(y)
}
adonovan and dmitshur
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.RefactoringIssues related to refactoring toolsIssues related to refactoring toolsgopls/analysisIssues related to running analysis in goplsIssues related to running analysis in gopls