|
| 1 | +package a |
| 2 | + |
| 3 | +type Floats struct { |
| 4 | + ValidString string |
| 5 | + |
| 6 | + ValidMap map[string]string |
| 7 | + |
| 8 | + ValidInt32 int32 |
| 9 | + |
| 10 | + ValidInt64 int64 |
| 11 | + |
| 12 | + InvalidFloat32 float32 // want "field InvalidFloat32 should not use a float value because they cannot be reliably round-tripped." |
| 13 | + |
| 14 | + InvalidFloat64 float64 // want "field InvalidFloat64 should not use a float value because they cannot be reliably round-tripped." |
| 15 | + |
| 16 | + InvalidFloat32Ptr *float32 // want "field InvalidFloat32Ptr pointer should not use a float value because they cannot be reliably round-tripped." |
| 17 | + |
| 18 | + InvalidFloat64Ptr *float64 // want "field InvalidFloat64Ptr pointer should not use a float value because they cannot be reliably round-tripped." |
| 19 | + |
| 20 | + InvalidFloat32Slice []float32 // want "field InvalidFloat32Slice array element should not use a float value because they cannot be reliably round-tripped." |
| 21 | + |
| 22 | + InvalidFloat64Slice []float64 // want "field InvalidFloat64Slice array element should not use a float value because they cannot be reliably round-tripped." |
| 23 | + |
| 24 | + InvalidFloat32PtrSlice []*float32 // want "field InvalidFloat32PtrSlice array element pointer should not use a float value because they cannot be reliably round-tripped." |
| 25 | + |
| 26 | + InvalidFloat64PtrSlice []*float64 // want "field InvalidFloat64PtrSlice array element pointer should not use a float value because they cannot be reliably round-tripped." |
| 27 | + |
| 28 | + InvalidFloat32Alias Float32Alias // want "field InvalidFloat32Alias type Float32Alias should not use a float value because they cannot be reliably round-tripped." |
| 29 | + |
| 30 | + InvalidFloat64Alias Float64Alias // want "field InvalidFloat64Alias type Float64Alias should not use a float value because they cannot be reliably round-tripped." |
| 31 | + |
| 32 | + InvalidFloat32PtrAlias *Float32Alias // want "field InvalidFloat32PtrAlias pointer type Float32Alias should not use a float value because they cannot be reliably round-tripped." |
| 33 | + |
| 34 | + InvalidFloat64PtrAlias *Float64Alias // want "field InvalidFloat64PtrAlias pointer type Float64Alias should not use a float value because they cannot be reliably round-tripped." |
| 35 | + |
| 36 | + InvalidFloat32SliceAlias []Float32Alias // want "field InvalidFloat32SliceAlias array element type Float32Alias should not use a float value because they cannot be reliably round-tripped." |
| 37 | + |
| 38 | + InvalidFloat64SliceAlias []Float64Alias // want "field InvalidFloat64SliceAlias array element type Float64Alias should not use a float value because they cannot be reliably round-tripped." |
| 39 | + |
| 40 | + InvalidFloat32PtrSliceAlias []*Float32Alias // want "field InvalidFloat32PtrSliceAlias array element pointer type Float32Alias should not use a float value because they cannot be reliably round-tripped." |
| 41 | + |
| 42 | + InvalidFloat64PtrSliceAlias []*Float64Alias // want "field InvalidFloat64PtrSliceAlias array element pointer type Float64Alias should not use a float value because they cannot be reliably round-tripped." |
| 43 | + |
| 44 | + InvalidMapStringToFloat32 map[string]float32 // want "field InvalidMapStringToFloat32 map value should not use a float value because they cannot be reliably round-tripped." |
| 45 | + |
| 46 | + InvalidMapStringToFloat64 map[string]float64 // want "field InvalidMapStringToFloat64 map value should not use a float value because they cannot be reliably round-tripped." |
| 47 | + |
| 48 | + InvalidMapStringToFloat32Ptr map[string]*float32 // want "field InvalidMapStringToFloat32Ptr map value pointer should not use a float value because they cannot be reliably round-tripped." |
| 49 | + |
| 50 | + InvalidMapStringToFloat64Ptr map[string]*float64 // want "field InvalidMapStringToFloat64Ptr map value pointer should not use a float value because they cannot be reliably round-tripped." |
| 51 | + |
| 52 | + InvalidMapFloat32ToString map[float32]string // want "field InvalidMapFloat32ToString map key should not use a float value because they cannot be reliably round-tripped." |
| 53 | + |
| 54 | + InvalidMapFloat64ToString map[float64]string // want "field InvalidMapFloat64ToString map key should not use a float value because they cannot be reliably round-tripped." |
| 55 | + |
| 56 | + InvalidMapFloat32PtrToString map[*float32]string // want "field InvalidMapFloat32PtrToString map key pointer should not use a float value because they cannot be reliably round-tripped." |
| 57 | + |
| 58 | + InvalidMapFloat64PtrToString map[*float64]string // want "field InvalidMapFloat64PtrToString map key pointer should not use a float value because they cannot be reliably round-tripped." |
| 59 | +} |
| 60 | + |
| 61 | +// DoNothingFloat32 is used to check that the analyser doesn't report on methods. |
| 62 | +func (Floats) DoNothingFloat32(a float32) float32 { |
| 63 | + return a |
| 64 | +} |
| 65 | + |
| 66 | +// DoNothingFloat64 is used to check that the analyser doesn't report on methods. |
| 67 | +func (Floats) DoNothingFloat64(a float64) float64 { |
| 68 | + return a |
| 69 | +} |
| 70 | + |
| 71 | +type Float32Alias float32 // want "type Float32Alias should not use a float value because they cannot be reliably round-tripped." |
| 72 | + |
| 73 | +type Float64Alias float64 // want "type Float64Alias should not use a float value because they cannot be reliably round-tripped." |
| 74 | + |
| 75 | +type Float32AliasPtr *float32 // want "type Float32AliasPtr pointer should not use a float value because they cannot be reliably round-tripped." |
| 76 | + |
| 77 | +type Float64AliasPtr *float64 // want "type Float64AliasPtr pointer should not use a float value because they cannot be reliably round-tripped." |
| 78 | + |
| 79 | +type Float32AliasSlice []float32 // want "type Float32AliasSlice array element should not use a float value because they cannot be reliably round-tripped." |
| 80 | + |
| 81 | +type Float64AliasSlice []float64 // want "type Float64AliasSlice array element should not use a float value because they cannot be reliably round-tripped." |
| 82 | + |
| 83 | +type Float32AliasPtrSlice []*float32 // want "type Float32AliasPtrSlice array element pointer should not use a float value because they cannot be reliably round-tripped." |
| 84 | + |
| 85 | +type Float64AliasPtrSlice []*float64 // want "type Float64AliasPtrSlice array element pointer should not use a float value because they cannot be reliably round-tripped." |
| 86 | + |
| 87 | +type MapStringToFloat32Alias map[string]float32 // want "type MapStringToFloat32Alias map value should not use a float value because they cannot be reliably round-tripped." |
| 88 | + |
| 89 | +type MapStringToFloat64Alias map[string]float64 // want "type MapStringToFloat64Alias map value should not use a float value because they cannot be reliably round-tripped." |
| 90 | + |
| 91 | +type MapStringToFloat32PtrAlias map[string]*float32 // want "type MapStringToFloat32PtrAlias map value pointer should not use a float value because they cannot be reliably round-tripped." |
| 92 | + |
| 93 | +type MapStringToFloat64PtrAlias map[string]*float64 // want "type MapStringToFloat64PtrAlias map value pointer should not use a float value because they cannot be reliably round-tripped." |
0 commit comments