Skip to content

User wonders whether this fd is garbage collected #2013

@gopherbot

Description

@gopherbot

by domo141:

What steps will reproduce the problem?

1. Read 'Effective Go' documentation

2. get into example

  f, err := os.Open(name, os.O_RDONLY, 0)
  if err != nil {
      return err
  }
  d, err := f.Stat()
  if err != nil {
      return err
  }
  codeUsing(f, d)
 
3. The following documentation says nothing about the fate of fd 'f'.

What is the expected output?

The document clearly explains that the fd opened with os.Open() is garbage
collected. If it is not, then example should be fixed to close 'f' before
returning.

What do you see instead?

no explanation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions