mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
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:
parent
1dad949142
commit
e5ffed35a4
4 changed files with 9 additions and 5 deletions
3
field.go
3
field.go
|
|
@ -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() {
|
||||
|
|
|
|||
3
index.go
3
index.go
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
6
view.go
6
view.go
|
|
@ -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{}{}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue