Skip to content

Instantly share code, notes, and snippets.

@meson10
Created August 30, 2015 08:56
Show Gist options
  • Save meson10/cfcad91115bf14d07a5d to your computer and use it in GitHub Desktop.
Save meson10/cfcad91115bf14d07a5d to your computer and use it in GitHub Desktop.
Generic Plugin Function.
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