golang.org/x/tools/gopls@v0.15.3/internal/analysis/simplifyslice/testdata/src/a/a.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package testdata 6 7 var ( 8 a [10]byte 9 b [20]float32 10 s []int 11 t struct { 12 s []byte 13 } 14 15 _ = a[0:] 16 _ = a[1:10] 17 _ = a[2:len(a)] // want "unneeded: len\\(a\\)" 18 _ = a[3:(len(a))] 19 _ = a[len(a)-1 : len(a)] // want "unneeded: len\\(a\\)" 20 _ = a[2:len(a):len(a)] 21 22 _ = a[:] 23 _ = a[:10] 24 _ = a[:len(a)] // want "unneeded: len\\(a\\)" 25 _ = a[:(len(a))] 26 _ = a[:len(a)-1] 27 _ = a[:len(a):len(a)] 28 29 _ = s[0:] 30 _ = s[1:10] 31 _ = s[2:len(s)] // want "unneeded: len\\(s\\)" 32 _ = s[3:(len(s))] 33 _ = s[len(a) : len(s)-1] 34 _ = s[0:len(b)] 35 _ = s[2:len(s):len(s)] 36 37 _ = s[:] 38 _ = s[:10] 39 _ = s[:len(s)] // want "unneeded: len\\(s\\)" 40 _ = s[:(len(s))] 41 _ = s[:len(s)-1] 42 _ = s[:len(b)] 43 _ = s[:len(s):len(s)] 44 45 _ = t.s[0:] 46 _ = t.s[1:10] 47 _ = t.s[2:len(t.s)] 48 _ = t.s[3:(len(t.s))] 49 _ = t.s[len(a) : len(t.s)-1] 50 _ = t.s[0:len(b)] 51 _ = t.s[2:len(t.s):len(t.s)] 52 53 _ = t.s[:] 54 _ = t.s[:10] 55 _ = t.s[:len(t.s)] 56 _ = t.s[:(len(t.s))] 57 _ = t.s[:len(t.s)-1] 58 _ = t.s[:len(b)] 59 _ = t.s[:len(t.s):len(t.s)] 60 ) 61 62 func _() { 63 s := s[0:len(s)] // want "unneeded: len\\(s\\)" 64 _ = s 65 } 66 67 func m() { 68 maps := []int{} 69 _ = maps[1:len(maps)] // want "unneeded: len\\(maps\\)" 70 }