An octal number is written with a leading 0 instead of the 0o prefix
What it finds
0755 is octal because of its leading zero, which is easy to miss and easy to add by accident, as in 0100 for a hundred. Since Go 1.13 the prefix 0o, as in 0o755, says it explicitly.
Integer literals of more than one digit that start with 0 followed by a digit are reported. The fix inserts the o and is safe, since the value stays the same.
From the rule's source, legacy_octal_literal.rs.
package p import "os" func f(path string) error { if err := os.Mkdir(path, 0755); err != nil {tx0 reports: this octal number reads better as 0o755 return err } return os.Chmod(path, 0o700|0)} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:legacy-octal-literal" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:legacy-octal-literal] reason="..."tx0 explain tx0/go:legacy-octal-literal shows the same in the terminal. Found a false positive? Report it.