use labeled targets for break statements

break in a select in a for terminates the current case of the
select, but does not terminate the for loop. The worker queue
implementations for opening indexes/fields/views all suffered
from the same issue here.

Also fix a `<= 0` on a uint value.

All hail staticcheck.
This commit is contained in:
Seebs 2019-10-11 14:44:25 -05:00
parent 1dad949142
commit e5ffed35a4
4 changed files with 9 additions and 5 deletions

View file

@ -468,10 +468,11 @@ func (f *Field) openViews() error {
eg, ctx := errgroup.WithContext(context.Background())
var mu sync.Mutex
fileLoop:
for _, loopFi := range fis {
select {
case <-ctx.Done():
break
break fileLoop
default:
fi := loopFi
if !fi.IsDir() {

View file

@ -174,10 +174,11 @@ func (i *Index) openFields() error {
eg, ctx := errgroup.WithContext(context.Background())
var mu sync.Mutex
fileLoop:
for _, loopFi := range fis {
select {
case <-ctx.Done():
break
break fileLoop
default:
fi := loopFi
if !fi.IsDir() {

View file

@ -301,7 +301,7 @@ func (s *InMemTranslateStore) TranslateIDs(ids []uint64) ([]string, error) {
}
func (s *InMemTranslateStore) translateID(id uint64) string {
if id <= 0 || id > uint64(len(s.keys)) {
if id == 0 || id > uint64(len(s.keys)) {
return ""
}
return s.keys[id-1]

View file

@ -134,10 +134,11 @@ func (v *view) openFragments() error {
eg, ctx := errgroup.WithContext(context.Background())
var mu sync.Mutex
fileLoop:
for _, loopFi := range fis {
select {
case <-ctx.Done():
break
break fileLoop
default:
fi := loopFi
@ -181,10 +182,11 @@ func (v *view) close() error {
// Close all fragments.
eg, ctx := errgroup.WithContext(context.Background())
fragLoop:
for _, loopFrag := range v.fragments {
select {
case <-ctx.Done():
break
break fragLoop
default:
frag := loopFrag
workQueue <- struct{}{}