Programming · Flashcard

What is the syntax for declaring a basic function in Go?

  • AThe func keyword, followed by the name, parentheses for parameters, and curly braces for the body
  • BThe function keyword, followed by the name, a colon, and the parameter list in angle brackets
  • CThe def keyword, followed by the name and an indented body block without any braces
  • DThe fn keyword, followed by the name and an arrow pointing to the return type and body

Why this is the answer

Functions are declared as func name(params) returnType { ... }. The func keyword is also used for methods and anonymous functions.

Official docs
Study in Gnoseed →