Callback in Golang, I'm trying to pass a function square (callback) and then a number to a function where the function square will return square of any number but it shows an error, 'function body missing'

package main

import “fmt”

func main() {

fmt.Println(squareMinusNum(square, 8))


func square (int num) int {

return num*num


func squareMinusNum (f(int num) int, num int) int{

x:= f(num)-num

return x



1 Like

Hey Sajir!

You just had a couple of easy fixes. In go the type comes after the name, for example func(num int) instead of func(int num), which is what you had.

Let me know if you have any more questions about this.

1 Like