Skip to content

Commit b2aa85b

Browse files
committed
io/ioutil: add doc links for deprecated function
Go1.19 introduced [doc link](https://go.dev/doc/comment#doclinks), It will be convenient when we can directly jump to the suggested function when the original function is deprecated.
1 parent af2bc6d commit b2aa85b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/io/ioutil/ioutil.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Package ioutil implements some I/O utility functions.
66
//
77
// Deprecated: As of Go 1.16, the same functionality is now provided
8-
// by package io or package os, and those implementations
8+
// by package [io] or package [os], and those implementations
99
// should be preferred in new code.
1010
// See the specific function documentation for details.
1111
package ioutil
@@ -22,7 +22,7 @@ import (
2222
// defined to read from src until EOF, it does not treat an EOF from Read
2323
// as an error to be reported.
2424
//
25-
// Deprecated: As of Go 1.16, this function simply calls io.ReadAll.
25+
// Deprecated: As of Go 1.16, this function simply calls [io.ReadAll].
2626
func ReadAll(r io.Reader) ([]byte, error) {
2727
return io.ReadAll(r)
2828
}
@@ -32,7 +32,7 @@ func ReadAll(r io.Reader) ([]byte, error) {
3232
// reads the whole file, it does not treat an EOF from Read as an error
3333
// to be reported.
3434
//
35-
// Deprecated: As of Go 1.16, this function simply calls os.ReadFile.
35+
// Deprecated: As of Go 1.16, this function simply calls [os.ReadFile].
3636
func ReadFile(filename string) ([]byte, error) {
3737
return os.ReadFile(filename)
3838
}
@@ -41,7 +41,7 @@ func ReadFile(filename string) ([]byte, error) {
4141
// If the file does not exist, WriteFile creates it with permissions perm
4242
// (before umask); otherwise WriteFile truncates it before writing, without changing permissions.
4343
//
44-
// Deprecated: As of Go 1.16, this function simply calls os.WriteFile.
44+
// Deprecated: As of Go 1.16, this function simply calls [os.WriteFile].
4545
func WriteFile(filename string, data []byte, perm fs.FileMode) error {
4646
return os.WriteFile(filename, data, perm)
4747
}
@@ -51,12 +51,12 @@ func WriteFile(filename string, data []byte, perm fs.FileMode) error {
5151
// sorted by filename. If an error occurs reading the directory,
5252
// ReadDir returns no directory entries along with the error.
5353
//
54-
// Deprecated: As of Go 1.16, os.ReadDir is a more efficient and correct choice:
55-
// it returns a list of fs.DirEntry instead of fs.FileInfo,
54+
// Deprecated: As of Go 1.16, [os.ReadDir] is a more efficient and correct choice:
55+
// it returns a list of [fs.DirEntry] instead of [fs.FileInfo],
5656
// and it returns partial results in the case of an error
5757
// midway through reading a directory.
5858
//
59-
// If you must continue obtaining a list of fs.FileInfo, you still can:
59+
// If you must continue obtaining a list of [fs.FileInfo], you still can:
6060
//
6161
// entries, err := os.ReadDir(dirname)
6262
// if err != nil { ... }
@@ -83,13 +83,13 @@ func ReadDir(dirname string) ([]fs.FileInfo, error) {
8383
// NopCloser returns a ReadCloser with a no-op Close method wrapping
8484
// the provided Reader r.
8585
//
86-
// Deprecated: As of Go 1.16, this function simply calls io.NopCloser.
86+
// Deprecated: As of Go 1.16, this function simply calls [io.NopCloser].
8787
func NopCloser(r io.Reader) io.ReadCloser {
8888
return io.NopCloser(r)
8989
}
9090

9191
// Discard is an io.Writer on which all Write calls succeed
9292
// without doing anything.
9393
//
94-
// Deprecated: As of Go 1.16, this value is simply io.Discard.
94+
// Deprecated: As of Go 1.16, this value is simply [io.Discard].
9595
var Discard io.Writer = io.Discard

src/io/ioutil/tempfile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
// to find the pathname of the file. It is the caller's responsibility
2121
// to remove the file when no longer needed.
2222
//
23-
// Deprecated: As of Go 1.17, this function simply calls os.CreateTemp.
23+
// Deprecated: As of Go 1.17, this function simply calls [os.CreateTemp].
2424
func TempFile(dir, pattern string) (f *os.File, err error) {
2525
return os.CreateTemp(dir, pattern)
2626
}
@@ -35,7 +35,7 @@ func TempFile(dir, pattern string) (f *os.File, err error) {
3535
// will not choose the same directory. It is the caller's responsibility
3636
// to remove the directory when no longer needed.
3737
//
38-
// Deprecated: As of Go 1.17, this function simply calls os.MkdirTemp.
38+
// Deprecated: As of Go 1.17, this function simply calls [os.MkdirTemp].
3939
func TempDir(dir, pattern string) (name string, err error) {
4040
return os.MkdirTemp(dir, pattern)
4141
}

0 commit comments

Comments
 (0)