aboutsummaryrefslogtreecommitdiff
path: root/src/strings
diff options
context:
space:
mode:
authorcui fliter <imcusg@gmail.com>2023-10-12 11:49:26 +0800
committerGopher Robot <gobot@golang.org>2023-10-13 17:10:31 +0000
commit6dd7462a04e2ce0a3e91cdb8fd85e98ac62ba0aa (patch)
tree40cf538d58215087be49a085f550cae7472a817c /src/strings
parenta0da9c00aeb51261b9845a46fbc9878870884ab6 (diff)
downloadgo-6dd7462a04e2ce0a3e91cdb8fd85e98ac62ba0aa.tar.gz
go-6dd7462a04e2ce0a3e91cdb8fd85e98ac62ba0aa.zip
bytes,strings: add available godoc link
Change-Id: Id9706a783d3321e3706eeee102286522e7968efd Reviewed-on: https://go-review.googlesource.com/c/go/+/534775 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/strings')
-rw-r--r--src/strings/builder.go4
-rw-r--r--src/strings/reader.go28
-rw-r--r--src/strings/replace.go2
-rw-r--r--src/strings/strings.go10
4 files changed, 22 insertions, 22 deletions
diff --git a/src/strings/builder.go b/src/strings/builder.go
index 299ad51255..189dadb1e7 100644
--- a/src/strings/builder.go
+++ b/src/strings/builder.go
@@ -10,7 +10,7 @@ import (
"unsafe"
)
-// A Builder is used to efficiently build a string using Write methods.
+// A Builder is used to efficiently build a string using [Builder.Write] methods.
// It minimizes memory copying. The zero value is ready to use.
// Do not copy a non-zero Builder.
type Builder struct {
@@ -57,7 +57,7 @@ func (b *Builder) Len() int { return len(b.buf) }
// already written.
func (b *Builder) Cap() int { return cap(b.buf) }
-// Reset resets the Builder to be empty.
+// Reset resets the [Builder] to be empty.
func (b *Builder) Reset() {
b.addr = nil
b.buf = nil
diff --git a/src/strings/reader.go b/src/strings/reader.go
index 04f31a1e8f..497ffb7a39 100644
--- a/src/strings/reader.go
+++ b/src/strings/reader.go
@@ -10,8 +10,8 @@ import (
"unicode/utf8"
)
-// A Reader implements the io.Reader, io.ReaderAt, io.ByteReader, io.ByteScanner,
-// io.RuneReader, io.RuneScanner, io.Seeker, and io.WriterTo interfaces by reading
+// A Reader implements the [io.Reader], [io.ReaderAt], [io.ByteReader], [io.ByteScanner],
+// [io.RuneReader], [io.RuneScanner], [io.Seeker], and [io.WriterTo] interfaces by reading
// from a string.
// The zero value for Reader operates like a Reader of an empty string.
type Reader struct {
@@ -30,12 +30,12 @@ func (r *Reader) Len() int {
}
// Size returns the original length of the underlying string.
-// Size is the number of bytes available for reading via ReadAt.
+// Size is the number of bytes available for reading via [Reader.ReadAt].
// The returned value is always the same and is not affected by calls
// to any other method.
func (r *Reader) Size() int64 { return int64(len(r.s)) }
-// Read implements the io.Reader interface.
+// Read implements the [io.Reader] interface.
func (r *Reader) Read(b []byte) (n int, err error) {
if r.i >= int64(len(r.s)) {
return 0, io.EOF
@@ -46,7 +46,7 @@ func (r *Reader) Read(b []byte) (n int, err error) {
return
}
-// ReadAt implements the io.ReaderAt interface.
+// ReadAt implements the [io.ReaderAt] interface.
func (r *Reader) ReadAt(b []byte, off int64) (n int, err error) {
// cannot modify state - see io.ReaderAt
if off < 0 {
@@ -62,7 +62,7 @@ func (r *Reader) ReadAt(b []byte, off int64) (n int, err error) {
return
}
-// ReadByte implements the io.ByteReader interface.
+// ReadByte implements the [io.ByteReader] interface.
func (r *Reader) ReadByte() (byte, error) {
r.prevRune = -1
if r.i >= int64(len(r.s)) {
@@ -73,7 +73,7 @@ func (r *Reader) ReadByte() (byte, error) {
return b, nil
}
-// UnreadByte implements the io.ByteScanner interface.
+// UnreadByte implements the [io.ByteScanner] interface.
func (r *Reader) UnreadByte() error {
if r.i <= 0 {
return errors.New("strings.Reader.UnreadByte: at beginning of string")
@@ -83,7 +83,7 @@ func (r *Reader) UnreadByte() error {
return nil
}
-// ReadRune implements the io.RuneReader interface.
+// ReadRune implements the [io.RuneReader] interface.
func (r *Reader) ReadRune() (ch rune, size int, err error) {
if r.i >= int64(len(r.s)) {
r.prevRune = -1
@@ -99,7 +99,7 @@ func (r *Reader) ReadRune() (ch rune, size int, err error) {
return
}
-// UnreadRune implements the io.RuneScanner interface.
+// UnreadRune implements the [io.RuneScanner] interface.
func (r *Reader) UnreadRune() error {
if r.i <= 0 {
return errors.New("strings.Reader.UnreadRune: at beginning of string")
@@ -112,7 +112,7 @@ func (r *Reader) UnreadRune() error {
return nil
}
-// Seek implements the io.Seeker interface.
+// Seek implements the [io.Seeker] interface.
func (r *Reader) Seek(offset int64, whence int) (int64, error) {
r.prevRune = -1
var abs int64
@@ -133,7 +133,7 @@ func (r *Reader) Seek(offset int64, whence int) (int64, error) {
return abs, nil
}
-// WriteTo implements the io.WriterTo interface.
+// WriteTo implements the [io.WriterTo] interface.
func (r *Reader) WriteTo(w io.Writer) (n int64, err error) {
r.prevRune = -1
if r.i >= int64(len(r.s)) {
@@ -152,9 +152,9 @@ func (r *Reader) WriteTo(w io.Writer) (n int64, err error) {
return
}
-// Reset resets the Reader to be reading from s.
+// Reset resets the [Reader] to be reading from s.
func (r *Reader) Reset(s string) { *r = Reader{s, 0, -1} }
-// NewReader returns a new Reader reading from s.
-// It is similar to bytes.NewBufferString but more efficient and non-writable.
+// NewReader returns a new [Reader] reading from s.
+// It is similar to [bytes.NewBufferString] but more efficient and non-writable.
func NewReader(s string) *Reader { return &Reader{s, 0, -1} }
diff --git a/src/strings/replace.go b/src/strings/replace.go
index f504fb48df..3b17a55b91 100644
--- a/src/strings/replace.go
+++ b/src/strings/replace.go
@@ -23,7 +23,7 @@ type replacer interface {
WriteString(w io.Writer, s string) (n int, err error)
}
-// NewReplacer returns a new Replacer from a list of old, new string
+// NewReplacer returns a new [Replacer] from a list of old, new string
// pairs. Replacements are performed in the order they appear in the
// target string, without overlapping matches. The old string
// comparisons are done in argument order.
diff --git a/src/strings/strings.go b/src/strings/strings.go
index ece7237c44..ce79bccf8c 100644
--- a/src/strings/strings.go
+++ b/src/strings/strings.go
@@ -272,7 +272,7 @@ func genSplit(s, sep string, sepSave, n int) []string {
// n < 0: all substrings
//
// Edge cases for s and sep (for example, empty strings) are handled
-// as described in the documentation for Split.
+// as described in the documentation for [Split].
//
// To split around the first instance of a separator, see Cut.
func SplitN(s, sep string, n int) []string { return genSplit(s, sep, 0, n) }
@@ -301,7 +301,7 @@ func SplitAfterN(s, sep string, n int) []string {
// If sep is empty, Split splits after each UTF-8 sequence. If both s
// and sep are empty, Split returns an empty slice.
//
-// It is equivalent to SplitN with a count of -1.
+// It is equivalent to [SplitN] with a count of -1.
//
// To split around the first instance of a separator, see Cut.
func Split(s, sep string) []string { return genSplit(s, sep, 0, -1) }
@@ -315,7 +315,7 @@ func Split(s, sep string) []string { return genSplit(s, sep, 0, -1) }
// If sep is empty, SplitAfter splits after each UTF-8 sequence. If
// both s and sep are empty, SplitAfter returns an empty slice.
//
-// It is equivalent to SplitAfterN with a count of -1.
+// It is equivalent to [SplitAfterN] with a count of -1.
func SplitAfter(s, sep string) []string {
return genSplit(s, sep, len(sep), -1)
}
@@ -904,7 +904,7 @@ func Trim(s, cutset string) string {
// TrimLeft returns a slice of the string s with all leading
// Unicode code points contained in cutset removed.
//
-// To remove a prefix, use TrimPrefix instead.
+// To remove a prefix, use [TrimPrefix] instead.
func TrimLeft(s, cutset string) string {
if s == "" || cutset == "" {
return s
@@ -952,7 +952,7 @@ func trimLeftUnicode(s, cutset string) string {
// TrimRight returns a slice of the string s, with all trailing
// Unicode code points contained in cutset removed.
//
-// To remove a suffix, use TrimSuffix instead.
+// To remove a suffix, use [TrimSuffix] instead.
func TrimRight(s, cutset string) string {
if s == "" || cutset == "" {
return s