| 1 |
package pkg |
| 2 |
|
| 3 |
import ( |
| 4 |
"io" |
| 5 |
"math" |
| 6 |
) |
| 7 |
|
| 8 |
type MyInt int |
| 9 |
|
| 10 |
const X int = 1 |
| 11 |
const Y = 1 |
| 12 |
|
| 13 |
func gen1() int { return 0 } |
| 14 |
func gen2() io.ReadCloser { return nil } |
| 15 |
func gen3() MyInt { return 0 } |
| 16 |
|
| 17 |
// don't flag global variables |
| 18 |
var a int = gen1() |
| 19 |
|
| 20 |
func fn() { |
| 21 |
var _ = gen1() //@ diag(`could omit type int`) |
| 22 |
var a = Y //@ diag(`could omit type int`) |
| 23 |
var b = 1 //@ diag(`could omit type int`) |
| 24 |
var c int = 1.0 // different default type |
| 25 |
var d MyInt = 1 // different default type |
| 26 |
var e = gen2() //@ diag(`could omit type io.ReadCloser`) |
| 27 |
var f io.Reader = gen2() // different interface type |
| 28 |
var g = math.Pi //@ diag(`could omit type float64`) |
| 29 |
var h = true //@ diag(`could omit type bool`) |
| 30 |
var i = "" //@ diag(`could omit type string`) |
| 31 |
var j = gen3() //@ diag(`could omit type MyInt`) |
| 32 |
var k uint8 = Y // different default type on constant |
| 33 |
var l uint8 = (Y + Y) / 2 // different default type on rhs |
| 34 |
var m = (Y + Y) / 2 //@ diag(`could omit type int`) |
| 35 |
|
| 36 |
_, _, _, _, _, _, _, _, _, _, _, _, _ = a, b, c, d, e, f, g, h, i, j, k, l, m |
| 37 |
} |