[go-nuts] Re: How to call function from struct in slice?

2022-06-04 Thread James Lei
I have nearly solve the problem, except I have to use cast as mod.(*Example1.AddModule) which is wrong. How do you cast as mod.(*AddModule)? On Saturday, 4 June 2022 at 11:40:15 UTC+8 Henry wrote: > You need to cast the generic interface{} to its appropriate type. For > instance: > > ``` >

[go-nuts] Re: How to call function from struct in slice?

2022-06-04 Thread James Lei
I tried your solution and it still can't find .ModuleName(), modules := vendorpackages.CompileModules() for _, module := range modules { mod, ok := module.(*AddModule) if !ok { //error handling if module is not of type AddModule } fmt.Println(mod.ModuleName()) //

[go-nuts] Re: How to call function from struct in slice?

2022-06-04 Thread James Lei
To add on, the return value of mod is "" fmt.Println(mod) On Saturday, 4 June 2022 at 11:40:15 UTC+8 Henry wrote: > You need to cast the generic interface{} to its appropriate type. For > instance: > > ``` > modules := CompileModules() > for _, module := range modules { > mod, ok := modu

[go-nuts] Re: How to call function from struct in slice?

2022-06-04 Thread jake...@gmail.com
I find your example code confusing, and it *appears* to have multiple syntax errors, which make it impossible to compile. If you could post a complete "working" example to the playground you would probably get a better response. On Thursday, June 2, 2022 at 8:17:04 AM UTC-4 Jay wrote: > > > I

[go-nuts] Re: How to call function from struct in slice?

2022-06-04 Thread Little Ant
Thank you Jake, I have not have a complete working solution, but I have included comments to understand the feature I'm trying to build to add or remove my custom modules similar to written CMS that add and remove modules/plugins. Unsure if I should go by "receiver" way or method way. https:/

Re: [go-nuts] custom linux shell that can run bash shell

2022-06-04 Thread Roland Müller
Hello, Am Freitag, 3. Juni 2022 schrieb Harsh Rathore : > Hello everyone, > so I am trying to make a custom linux shell in golang, among other things, I want this shell to be able to run BASH shell. > Like when we are prompted with sh shell > $ Of course it is feasable to make a Golang remake of

[go-nuts] Re: How to call function from struct in slice?

2022-06-04 Thread Henry
I have no idea what problem you are facing. Your example is not clear enough to me. I think you may have several other problems in the mix as well (such as calling code from another package, etc.). Try reading the compiler error and see if it helps. I have included a more elaborate example. Ho