Skip to content

testing: rename t.TempDir to t.Mkdir #39169

Description

@rogpeppe

The originally proposed name for testing.T.TempDir was Mkdir. The name was changed during the proposal process. There has been some confusion about the intended semantics: is it more like ioutil.TempDir or os.TempDir ?

To avoid the confusion, I suggest that we use the originally proposed name, Mkdir. It's then very clear that the method is creating a new directory. The fact that the method has no arguments is a clear indication that the directory name is chosen by the method itself rather than by the caller.

Activity

  1. mvdan commented on May 20, 2020

    @mvdan
    Member

    I was initially against this name, because I thought testing.T.Mkdir could be confused for os.Mkdir. But Roger correctly pointed out that's very unlikely, since testing.T.Mkdir does not take any arguments.

  2. added this to the Go1.15 milestone on May 20, 2020
  3. gopherbot commented on May 20, 2020

    @gopherbot
    Contributor

    Change https://golang.org/cl/234558 mentions this issue: testing: rename TempDir to Mkdir

  4. rsc commented on May 20, 2020

    @rsc
    Contributor

    Mkdir does not convey "this is temporary". (It's not ioutil.Mkdir.) Let's leave it as TempDir. I understand the conflict with os.TempDir, but more people know about ioutil.TempDir anyway. Thanks.

  5. rogpeppe commented on May 20, 2020

    @rogpeppe
    ContributorAuthor

    Fair enough. Will close.

  6. locked and limited conversation to collaborators on May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions