Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: clarify os.(*File).Close() behaviour #32427

Closed
icholy opened this issue Jun 4, 2019 · 1 comment
Closed

doc: clarify os.(*File).Close() behaviour #32427

icholy opened this issue Jun 4, 2019 · 1 comment
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge

Comments

@icholy
Copy link

icholy commented Jun 4, 2019

The current documentation for os.(*File).Close() doesn't specify whether it's safe to call Close multiple times.

This is useful for code like this:

func doSomething() error {
    f, err := os.Create("foo")
    if err != nil {
        return err
    }
    defer f.Close()
    if _, err := f.Write([]byte("bar"); err != nil {
        return err
    }
    return f.Close()
}

System details

go version go1.12 linux/amd64
GOARCH="amd64"
GOBIN="/home/icholy/go/bin"
GOCACHE="/home/icholy/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/icholy/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
GOROOT/bin/go version: go version go1.12 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.12
uname -sr: Linux 4.4.0-148-generic
LSB Version:	core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
Codename:	xenial
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.23-0ubuntu11) stable release version 2.23, by Roland McGrath et al.
gdb --version: GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
@gopherbot gopherbot added the Documentation Issues describing a change to documentation. label Jun 4, 2019
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/180438 mentions this issue: doc: clarify safety of mupltiple and concurent os.(*File).Close() calls

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

2 participants