How to call Name() from slice?

70 views
Skip to first unread message

Jay

unread,
Jun 2, 2022, 8:17:09 AM6/2/22
to golang-nuts

In a code example, I’m confuse if it’s possible to call ModuleName() each package API after execute CompileModules()?


app.go


func CompileModules() []interface{

    return []interface{

        Example1.AddModule(),

        Example2.AddModule(),

        Example3.AddModule(),

    }

}




Init.go in Hello1 folder:

package Example1


type AddModule struct {}


func (p *AddModule) ModuleName() string {

    return “Hello 1”

}

Reply all
Reply to author
Forward
0 new messages