Commit fc705275 authored by Alex Myasoedov's avatar Alex Myasoedov Committed by Rob Pike

doc: clarify safety of multiple and concurent os.(*File).Close() calls

Fixes #32427

Change-Id: I4b863bd3836067dcc2eb3a9c3a7169656763d003
Reviewed-on: https://go-review.googlesource.com/c/go/+/180438Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: default avatarRob Pike <r@golang.org>
parent 49200e3f
...@@ -136,6 +136,7 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) { ...@@ -136,6 +136,7 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) {
// Close closes the File, rendering it unusable for I/O. // Close closes the File, rendering it unusable for I/O.
// On files that support SetDeadline, any pending I/O operations will // On files that support SetDeadline, any pending I/O operations will
// be canceled and return immediately with an error. // be canceled and return immediately with an error.
// Close will return an error if it has already been called.
func (f *File) Close() error { func (f *File) Close() error {
if err := f.checkValid("close"); err != nil { if err := f.checkValid("close"); err != nil {
return err return err
......
...@@ -225,6 +225,7 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) { ...@@ -225,6 +225,7 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) {
// Close closes the File, rendering it unusable for I/O. // Close closes the File, rendering it unusable for I/O.
// On files that support SetDeadline, any pending I/O operations will // On files that support SetDeadline, any pending I/O operations will
// be canceled and return immediately with an error. // be canceled and return immediately with an error.
// Close will return an error if it has already been called.
func (f *File) Close() error { func (f *File) Close() error {
if f == nil { if f == nil {
return ErrInvalid return ErrInvalid
......
...@@ -178,6 +178,7 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) { ...@@ -178,6 +178,7 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) {
// Close closes the File, rendering it unusable for I/O. // Close closes the File, rendering it unusable for I/O.
// On files that support SetDeadline, any pending I/O operations will // On files that support SetDeadline, any pending I/O operations will
// be canceled and return immediately with an error. // be canceled and return immediately with an error.
// Close will return an error if it has already been called.
func (file *File) Close() error { func (file *File) Close() error {
if file == nil { if file == nil {
return ErrInvalid return ErrInvalid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment