0PricingLogin
Go Academy · Lesson

Function Basics and Signatures

Parameters, return types, and calling conventions

Defining a Function

In Go, functions are defined with the func keyword:

func greet(name string) string {
    return "Hello, " + name
}

Parameters and Arguments

Parameters are typed and listed as name type pairs. Multiple parameters of the same type can share the type annotation:

func add(x, y int) int {
    return x + y
}

func rect(w, h float64) float64 {
    return w * h
}

All lessons in this course

  1. Function Basics and Signatures
  2. Multiple Return Values
  3. Variadic Functions
  4. defer, Anonymous Functions & Closures
← Back to Go Academy