# Go: ./main.go:18:1: missing return

**Code:** `missing return` · **Category:** Go · **Seen on:** Go

A function with a return type can reach its end without a return statement on some path.

## Meaning

Go requires every control-flow path of a non-void function to end in a terminating statement (`return`, `panic`, an infinite `for {}`, or an exhaustive `switch` with default that returns). An `if/else` chain without final `else` or a `for` with a condition does not count.

## Common causes

- if/else if chain missing a final return
- Loop with a condition then fall off the end
- switch without a default case
- Return only inside an if
- Function ends with a log call instead of return/panic

## Quick fix

1. Add a final `return` (or `panic`) after the loop or conditional
2. Add `default:` to switch statements
3. Restructure to return early

## Detailed fix by platform

### Go

1. `go vet ./...` highlights unreachable and missing returns

## How to diagnose

1. **Paths** — Every path returns?
2. **Switch** — default present?
3. **Loop** — Can it exit?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/go/missing-return)
