Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Module and BaseModule. Closes #1
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package alice | ||
|
||
// Module is a marker interface for structs that defines how to initialize instances. | ||
type Module interface { | ||
// IsModule indicates if this is a module. | ||
IsModule() bool | ||
} | ||
|
||
// BaseModule is an implementation of Module interface. It should be embeded into each module defined in the | ||
// application. | ||
type BaseModule struct{} | ||
|
||
// IsModule indicates it is a module. | ||
func (b *BaseModule) IsModule() bool { | ||
return true | ||
} |
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,12 @@ | ||
package alice | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestBaseModule(t *testing.T) { | ||
var base Module = &BaseModule{} | ||
if !base.IsModule() { | ||
t.Error("BaseModule is expected to be a Module, but it is not") | ||
} | ||
} |