Pointer to a function in Golang

Go has no apparent “pointer to a function” but it can store the functions and call it later making the function pointers implicitly defined.

What is a function pointer?

In some programming languages like C/C++, there can be a pointer that can store the address of a function and later call it using itself. This is called a function pointer. Go doesn’t have support for function pointers due to design decisions focusing on simplicity.

The implicit definition

Go has implicit support for function pointers due to the fact that we can store functions and call them using other variables. That means having support for first-class functions.

Is function pointers really needed in Go?

Go committee took the design decision to make the language as simple as possible. So, avoiding the function pointers explicitly is a way to go. The function pointers can get complicated really quickly. We must be aware of that, as can be seen in those programming languages.

So, it can be concluded that it is not needed since the implicit support renders the functions as a first-class citizen in Go.