mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +02:00
feature: new rule use-fmt-print (#1389)
print and println built-in functions are not recommended for use-cases other than language boostraping and are not guaranteed to stay in the language. This commit adds a new rule, use-fmt-print, that spots uses of print and println, and recommends using their fmt equivalents.
This commit is contained in:
24
testdata/use_fmt_print_with_redefinition.go
vendored
Normal file
24
testdata/use_fmt_print_with_redefinition.go
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package fixtures
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func print() {}
|
||||
func println() {}
|
||||
|
||||
type useFmtPrintT struct{}
|
||||
|
||||
func (useFmtPrintT) print(s string) {}
|
||||
func (useFmtPrintT) println(s string) {}
|
||||
|
||||
func useFmtPrint() {
|
||||
fmt.Println("just testing")
|
||||
fmt.Print("just testing")
|
||||
t := useFmtPrintT{}
|
||||
t.print("just testing")
|
||||
t.println("just testing")
|
||||
|
||||
println("just testing")
|
||||
print("just testing")
|
||||
}
|
||||
Reference in New Issue
Block a user