prysm-pulse/tools/analyzers/slicedirect/testdata/slice.go
terence tsao d5ec248691
Rename getter functions to be idiomatic (#8320)
* Rename getter functions

* Rename new

* Radek's feedback

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2021-01-25 21:27:30 +00:00

47 lines
730 B
Go

package testdata
func NoIndexProvided() {
x := []byte{'f', 'o', 'o'}
y := x[:] // want "Expression is already a slice."
if len(y) == 3 {
}
}
func StartIndexProvided_NoDiagnostic() {
x := []byte{'f', 'o', 'o'}
y := x[1:]
if len(y) == 3 {
}
}
func EndIndexProvided_NoDiagnostic() {
x := []byte{'f', 'o', 'o'}
y := x[:2]
if len(y) == 3 {
}
}
func BothIndicesProvided_NoDiagnostic() {
x := []byte{'f', 'o', 'o'}
y := x[1:2]
if len(y) == 3 {
}
}
func StringSlice() {
x := "foo"
y := x[:] // want "Expression is already a slice."
if len(y) == 3 {
}
}
func SliceFromFunction() {
x := slice()[:] // want "Expression is already a slice."
if len(x) == 3 {
}
}
func slice() []string {
return []string{"bar"}
}