-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from spiral/bug/collects_loop_issue
fix(collects): Bug in the Collects loop with early exit
- Loading branch information
Showing
11 changed files
with
142 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ linters: | |
- nakedret | ||
- nolintlint | ||
- rowserrcheck | ||
- scopelint | ||
- staticcheck | ||
- structcheck | ||
- typecheck | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,4 +64,4 @@ func main() { | |
return | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/interfaces/collects/collects_get_all_deps/plugin1.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package collects_get_all_deps | ||
|
||
type Plugin1 struct { | ||
} | ||
|
||
type SuperInterface interface { | ||
Super() string | ||
} | ||
|
||
type Super2Interface interface { | ||
Super2() string | ||
} | ||
|
||
func (f *Plugin1) Init() error { | ||
return nil | ||
} | ||
|
||
func (f *Plugin1) Serve() chan error { | ||
errCh := make(chan error) | ||
return errCh | ||
} | ||
|
||
func (f *Plugin1) Stop() error { | ||
return nil | ||
} | ||
|
||
// Super and Super2 interface impl | ||
func (f *Plugin1) Super() string { | ||
return "SUPER -> " | ||
} | ||
|
||
func (f *Plugin1) Super2() string { | ||
return "I'm also SUPER2 -> " | ||
} |
40 changes: 40 additions & 0 deletions
40
tests/interfaces/collects/collects_get_all_deps/plugin2.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package collects_get_all_deps | ||
|
||
import "github.com/spiral/errors" | ||
|
||
type Plugin2 struct { | ||
collectsDeps []interface{} | ||
} | ||
|
||
func (f *Plugin2) Init() error { | ||
// should be 2 deps | ||
f.collectsDeps = make([]interface{}, 0, 2) | ||
return nil | ||
} | ||
|
||
func (f *Plugin2) Serve() chan error { | ||
errCh := make(chan error) | ||
if len(f.collectsDeps) != 2 { | ||
errCh <- errors.E("not enough deps collected") | ||
} | ||
return errCh | ||
} | ||
|
||
func (f *Plugin2) Stop() error { | ||
return nil | ||
} | ||
|
||
func (f *Plugin2) Collects() []interface{} { | ||
return []interface{}{ | ||
f.GetSuper, | ||
f.GetSuper2, | ||
} | ||
} | ||
|
||
func (f *Plugin2) GetSuper(s SuperInterface) { | ||
f.collectsDeps = append(f.collectsDeps, s) | ||
} | ||
|
||
func (f *Plugin2) GetSuper2(s Super2Interface) { | ||
f.collectsDeps = append(f.collectsDeps, s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters