Skip to content

Functions and Methods

Functions in Targo look familiar if you know TypeScript, but return-value design and error flow are Go-first.

Think in three buckets

Pure functions

Use them for:

  • value transforms
  • domain rules
  • synchronous business logic

Fallible functions

Prefer:

  • [T, error | null]
  • explicit error checks
  • explicit propagation or wrapping

Methods

Use methods when behavior is tightly coupled to a structure.
Do not turn every helper into a method just to mimic OO style.