package main

import (
	"errors"
	"fmt"
	"time"
)

// section: fixed
func sendResult(ch chan string, err error) {
	if err != nil {
		ch <- "error occurred"
		return // FIXED: explicit return after send
	}
	ch <- "success"
}

// section: fixed

func main() {
	ch := make(chan string, 1)

	go sendResult(ch, errors.New("something went wrong"))

	result := <-ch
	fmt.Println("Got:", result)

	time.Sleep(100 * time.Millisecond)
	fmt.Println("Goroutine completed cleanly - no leak")
}
