Functions

Contents

Functions#

Function values are typed by their signature. The operator can bind functions to names, store them in structs, and pass them as arguments.

Name a function type.

type Handler func(req string) error

Bind a function value to the named type.

var h Handler = func(req string) error {
    fmt.Println(req)
    return nil
}

References#

  • Functions for the full function surface.

  • Interfaces for interfaces that include a function-like method set.