From fc705275c34233ffc1cb34be965f289589de9ba6 Mon Sep 17 00:00:00 2001
From: Alex Myasoedov <msoedov@gmail.com>
Date: Tue, 4 Jun 2019 20:07:57 +0200
Subject: [PATCH] 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/+/180438
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
---
 src/os/file_plan9.go   | 1 +
 src/os/file_unix.go    | 1 +
 src/os/file_windows.go | 1 +
 3 files changed, 3 insertions(+)

diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go
index 14091873cf9..e0a3826a34c 100644
--- a/src/os/file_plan9.go
+++ b/src/os/file_plan9.go
@@ -136,6 +136,7 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) {
 // Close closes the File, rendering it unusable for I/O.
 // On files that support SetDeadline, any pending I/O operations will
 // be canceled and return immediately with an error.
+// Close will return an error if it has already been called.
 func (f *File) Close() error {
 	if err := f.checkValid("close"); err != nil {
 		return err
diff --git a/src/os/file_unix.go b/src/os/file_unix.go
index 89c05b26572..754e8596453 100644
--- a/src/os/file_unix.go
+++ b/src/os/file_unix.go
@@ -225,6 +225,7 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) {
 // Close closes the File, rendering it unusable for I/O.
 // On files that support SetDeadline, any pending I/O operations will
 // be canceled and return immediately with an error.
+// Close will return an error if it has already been called.
 func (f *File) Close() error {
 	if f == nil {
 		return ErrInvalid
diff --git a/src/os/file_windows.go b/src/os/file_windows.go
index 08444d728f6..1e78f4e8670 100644
--- a/src/os/file_windows.go
+++ b/src/os/file_windows.go
@@ -178,6 +178,7 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) {
 // Close closes the File, rendering it unusable for I/O.
 // On files that support SetDeadline, any pending I/O operations will
 // be canceled and return immediately with an error.
+// Close will return an error if it has already been called.
 func (file *File) Close() error {
 	if file == nil {
 		return ErrInvalid
-- 
GitLab