Reports potential resource leaks, such as unclosed files, SQL rows, HTTP response bodies, or other resources that implement io.Closer and require explicit closure.

Example:


func readFile() ([]byte, error) {
    f, err := os.Open("data.txt") // resource leak: not closed on all paths
    if err != nil {
        return nil, err
    }

    data, err := io.ReadAll(f)
    if err != nil {
        return nil, err // 'f' is not closed here
    }

    f.Close()
    return data, nil
}