Created
August 30, 2015 08:56
-
-
Save meson10/cfcad91115bf14d07a5d to your computer and use it in GitHub Desktop.
Generic Plugin Function.
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
package main | |
import ( | |
"fmt" | |
) | |
type BaseApp interface { | |
Name() | |
} | |
type App interface { | |
BaseApp | |
AddPlugin(interface{}) | |
Plugins() []interface{} | |
} | |
type AppOne struct { | |
plugins []func() bool | |
} | |
func (self *AppOne) AddPlugin(fn func() bool) { | |
self.plugins = append(self.plugins, fn) | |
} | |
func (self *AppOne) Plugins() []func() bool { | |
return self.plugins | |
} | |
func GetApp() App { | |
x := AppOne{} | |
return x | |
} | |
func main() { | |
fmt.Println(GetApp()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment