github.com/yandex/pandora@v0.5.32/core/plugin/example_test.go (about)

     1  package plugin_test
     2  
     3  import "github.com/yandex/pandora/core/plugin"
     4  
     5  type Plugin interface {
     6  	DoSmth()
     7  }
     8  
     9  func RegisterPlugin(name string, newPluginImpl interface{}, newDefaultConfigOptional ...interface{}) {
    10  	var p Plugin
    11  	plugin.Register(plugin.PtrType(&p), name, newPluginImpl, newDefaultConfigOptional...)
    12  }
    13  
    14  func ExampleRegister() {
    15  	type Conf struct{ Smth string }
    16  	New := func(Conf) Plugin { panic("") }
    17  	RegisterPlugin("no-default", New)
    18  	RegisterPlugin("default", New, func() Conf { return Conf{"example"} })
    19  }