mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
Add stringintconv and ifaceassert to govet (#1360)
This commit is contained in:
parent
191d6c873b
commit
f00da2c0b7
3 changed files with 25 additions and 1 deletions
7
test/testdata/govet.go
vendored
7
test/testdata/govet.go
vendored
|
@ -8,7 +8,7 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
func Govet() error {
|
||||
func GovetComposites() error {
|
||||
return &os.PathError{"first", "path", os.ErrNotExist} // ERROR "composites: \\`(os|io/fs)\\.PathError\\` composite literal uses unkeyed fields"
|
||||
}
|
||||
|
||||
|
@ -36,3 +36,8 @@ func GovetPrintf() {
|
|||
x := "dummy"
|
||||
fmt.Printf("%d", x) // ERROR "printf: Printf format %d has arg x of wrong type string"
|
||||
}
|
||||
|
||||
func GovetStringIntConv() {
|
||||
i := 42
|
||||
fmt.Println("i = " + string(i)) // ERROR "stringintconv: conversion from int to string yields a string of one rune, not a string of digits \\(did you mean fmt.Sprint\\(x\\)\\?\\)"
|
||||
}
|
||||
|
|
14
test/testdata/govet_ifaceassert.go
vendored
Normal file
14
test/testdata/govet_ifaceassert.go
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
//args: -Egovet
|
||||
//config: linters-settings.govet.enable=ifaceassert
|
||||
package testdata
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
func GovetIfaceAssert() {
|
||||
var v interface {
|
||||
Read()
|
||||
}
|
||||
_ = v.(io.Reader) // ERROR "impossible type assertion: no type can implement both interface\\{Read\\(\\)\\} and io\\.Reader \\(conflicting types for Read method\\)"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue