Calling methods from inside a function in same package

53 views
Skip to first unread message

Rudra

unread,
Jul 21, 2020, 12:51:20 PM7/21/20
to golang-nuts
Hi,
One can call global function of same package from inside a function, But I am curious if I can call a method from inside a function?

Tyler Compton

unread,
Jul 21, 2020, 2:42:12 PM7/21/20
to Rudra, golang-nuts
I think I'm very likely misunderstanding your question. Would you mind providing more detail?

You can definitely call methods within a function, even if they're defined in the same package. In this example, I call a method from the type "myInt" in the main function: https://play.golang.org/p/AAjVZCncUFJ


On Tue, Jul 21, 2020 at 9:51 AM Rudra <itzru...@gmail.com> wrote:
Hi,
One can call global function of same package from inside a function, But I am curious if I can call a method from inside a function?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/cc1869a9-d6a2-4a2f-890d-d728439fa4c0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages