Skip to content

Commit d9f9746

Browse files
cuishuangneild
authored andcommitted
mime: add available godoc link
Change-Id: I66ec9edc71f4c1207135e4248003a7457e456931 Reviewed-on: https://go-review.googlesource.com/c/go/+/539576 Reviewed-by: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: David Chase <[email protected]> Run-TryBot: shuang cui <[email protected]>
1 parent cff7267 commit d9f9746

File tree

7 files changed

+31
-30
lines changed

7 files changed

+31
-30
lines changed

Diff for: src/mime/encodedword.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (d *WordDecoder) Decode(word string) (string, error) {
226226
}
227227

228228
// DecodeHeader decodes all encoded-words of the given string. It returns an
229-
// error if and only if CharsetReader of d returns an error.
229+
// error if and only if WordDecoder.CharsetReader of d returns an error.
230230
func (d *WordDecoder) DecodeHeader(header string) (string, error) {
231231
// If there is no encoded-word, returns before creating a buffer.
232232
i := strings.Index(header, "=?")

Diff for: src/mime/mediatype.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func checkMediaTypeDisposition(s string) error {
121121
return nil
122122
}
123123

124-
// ErrInvalidMediaParameter is returned by ParseMediaType if
124+
// ErrInvalidMediaParameter is returned by [ParseMediaType] if
125125
// the media type value was found but there was an error parsing
126126
// the optional parameters
127127
var ErrInvalidMediaParameter = errors.New("mime: invalid media parameter")
@@ -133,7 +133,7 @@ var ErrInvalidMediaParameter = errors.New("mime: invalid media parameter")
133133
// to lowercase and trimmed of white space and a non-nil map.
134134
// If there is an error parsing the optional parameter,
135135
// the media type will be returned along with the error
136-
// ErrInvalidMediaParameter.
136+
// [ErrInvalidMediaParameter].
137137
// The returned map, params, maps from the lowercase
138138
// attribute to the attribute value with its case preserved.
139139
func ParseMediaType(v string) (mediatype string, params map[string]string, err error) {

Diff for: src/mime/multipart/formdata.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var ErrMessageTooLarge = errors.New("multipart: message too large")
2727
// It stores up to maxMemory bytes + 10MB (reserved for non-file parts)
2828
// in memory. File parts which can't be stored in memory will be stored on
2929
// disk in temporary files.
30-
// It returns ErrMessageTooLarge if all non-file parts can't be stored in
30+
// It returns [ErrMessageTooLarge] if all non-file parts can't be stored in
3131
// memory.
3232
func (r *Reader) ReadForm(maxMemory int64) (*Form, error) {
3333
return r.readForm(maxMemory)
@@ -228,15 +228,15 @@ func mimeHeaderSize(h textproto.MIMEHeader) (size int64) {
228228

229229
// Form is a parsed multipart form.
230230
// Its File parts are stored either in memory or on disk,
231-
// and are accessible via the *FileHeader's Open method.
231+
// and are accessible via the [*FileHeader]'s Open method.
232232
// Its Value parts are stored as strings.
233233
// Both are keyed by field name.
234234
type Form struct {
235235
Value map[string][]string
236236
File map[string][]*FileHeader
237237
}
238238

239-
// RemoveAll removes any temporary files associated with a Form.
239+
// RemoveAll removes any temporary files associated with a [Form].
240240
func (f *Form) RemoveAll() error {
241241
var err error
242242
for _, fhs := range f.File {
@@ -264,7 +264,7 @@ type FileHeader struct {
264264
tmpshared bool
265265
}
266266

267-
// Open opens and returns the FileHeader's associated File.
267+
// Open opens and returns the [FileHeader]'s associated File.
268268
func (fh *FileHeader) Open() (File, error) {
269269
if b := fh.content; b != nil {
270270
r := io.NewSectionReader(bytes.NewReader(b), 0, int64(len(b)))

Diff for: src/mime/multipart/multipart.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ bodies generated by popular browsers.
1515
To protect against malicious inputs, this package sets limits on the size
1616
of the MIME data it processes.
1717
18-
Reader.NextPart and Reader.NextRawPart limit the number of headers in a
19-
part to 10000 and Reader.ReadForm limits the total number of headers in all
18+
[Reader.NextPart] and [Reader.NextRawPart] limit the number of headers in a
19+
part to 10000 and [Reader.ReadForm] limits the total number of headers in all
2020
FileHeaders to 10000.
2121
These limits may be adjusted with the GODEBUG=multipartmaxheaders=<values>
2222
setting.
@@ -85,7 +85,7 @@ func (p *Part) FormName() string {
8585
return p.dispositionParams["name"]
8686
}
8787

88-
// FileName returns the filename parameter of the Part's Content-Disposition
88+
// FileName returns the filename parameter of the [Part]'s Content-Disposition
8989
// header. If not empty, the filename is passed through filepath.Base (which is
9090
// platform dependent) before being returned.
9191
func (p *Part) FileName() string {
@@ -110,11 +110,11 @@ func (p *Part) parseContentDisposition() {
110110
}
111111
}
112112

113-
// NewReader creates a new multipart Reader reading from r using the
113+
// NewReader creates a new multipart [Reader] reading from r using the
114114
// given MIME boundary.
115115
//
116116
// The boundary is usually obtained from the "boundary" parameter of
117-
// the message's "Content-Type" header. Use mime.ParseMediaType to
117+
// the message's "Content-Type" header. Use [mime.ParseMediaType] to
118118
// parse such headers.
119119
func NewReader(r io.Reader, boundary string) *Reader {
120120
b := []byte("\r\n--" + boundary + "--")
@@ -363,7 +363,7 @@ func maxMIMEHeaders() int64 {
363363
}
364364

365365
// NextPart returns the next part in the multipart or an error.
366-
// When there are no more parts, the error io.EOF is returned.
366+
// When there are no more parts, the error [io.EOF] is returned.
367367
//
368368
// As a special case, if the "Content-Transfer-Encoding" header
369369
// has a value of "quoted-printable", that header is instead
@@ -373,9 +373,9 @@ func (r *Reader) NextPart() (*Part, error) {
373373
}
374374

375375
// NextRawPart returns the next part in the multipart or an error.
376-
// When there are no more parts, the error io.EOF is returned.
376+
// When there are no more parts, the error [io.EOF] is returned.
377377
//
378-
// Unlike NextPart, it does not have special handling for
378+
// Unlike [Reader.NextPart], it does not have special handling for
379379
// "Content-Transfer-Encoding: quoted-printable".
380380
func (r *Reader) NextRawPart() (*Part, error) {
381381
return r.nextPart(true, maxMIMEHeaderSize, maxMIMEHeaders())

Diff for: src/mime/multipart/readmimeheader.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// Copyright 2023 The Go Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
4+
45
package multipart
56

67
import (
78
"net/textproto"
89
_ "unsafe" // for go:linkname
910
)
1011

11-
// readMIMEHeader is defined in package net/textproto.
12+
// readMIMEHeader is defined in package [net/textproto].
1213
//
1314
//go:linkname readMIMEHeader net/textproto.readMIMEHeader
1415
func readMIMEHeader(r *textproto.Reader, maxMemory, maxHeaders int64) (textproto.MIMEHeader, error)

Diff for: src/mime/multipart/writer.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Writer struct {
2222
lastpart *part
2323
}
2424

25-
// NewWriter returns a new multipart Writer with a random boundary,
25+
// NewWriter returns a new multipart [Writer] with a random boundary,
2626
// writing to w.
2727
func NewWriter(w io.Writer) *Writer {
2828
return &Writer{
@@ -31,12 +31,12 @@ func NewWriter(w io.Writer) *Writer {
3131
}
3232
}
3333

34-
// Boundary returns the Writer's boundary.
34+
// Boundary returns the [Writer]'s boundary.
3535
func (w *Writer) Boundary() string {
3636
return w.boundary
3737
}
3838

39-
// SetBoundary overrides the Writer's default randomly-generated
39+
// SetBoundary overrides the [Writer]'s default randomly-generated
4040
// boundary separator with an explicit value.
4141
//
4242
// SetBoundary must be called before any parts are created, may only
@@ -70,7 +70,7 @@ func (w *Writer) SetBoundary(boundary string) error {
7070
}
7171

7272
// FormDataContentType returns the Content-Type for an HTTP
73-
// multipart/form-data with this Writer's Boundary.
73+
// multipart/form-data with this [Writer]'s Boundary.
7474
func (w *Writer) FormDataContentType() string {
7575
b := w.boundary
7676
// We must quote the boundary if it contains any of the
@@ -92,7 +92,7 @@ func randomBoundary() string {
9292

9393
// CreatePart creates a new multipart section with the provided
9494
// header. The body of the part should be written to the returned
95-
// Writer. After calling CreatePart, any previous part may no longer
95+
// [Writer]. After calling CreatePart, any previous part may no longer
9696
// be written to.
9797
func (w *Writer) CreatePart(header textproto.MIMEHeader) (io.Writer, error) {
9898
if w.lastpart != nil {
@@ -135,7 +135,7 @@ func escapeQuotes(s string) string {
135135
return quoteEscaper.Replace(s)
136136
}
137137

138-
// CreateFormFile is a convenience wrapper around CreatePart. It creates
138+
// CreateFormFile is a convenience wrapper around [Writer.CreatePart]. It creates
139139
// a new form-data header with the provided field name and file name.
140140
func (w *Writer) CreateFormFile(fieldname, filename string) (io.Writer, error) {
141141
h := make(textproto.MIMEHeader)
@@ -146,7 +146,7 @@ func (w *Writer) CreateFormFile(fieldname, filename string) (io.Writer, error) {
146146
return w.CreatePart(h)
147147
}
148148

149-
// CreateFormField calls CreatePart with a header using the
149+
// CreateFormField calls [Writer.CreatePart] with a header using the
150150
// given field name.
151151
func (w *Writer) CreateFormField(fieldname string) (io.Writer, error) {
152152
h := make(textproto.MIMEHeader)
@@ -155,7 +155,7 @@ func (w *Writer) CreateFormField(fieldname string) (io.Writer, error) {
155155
return w.CreatePart(h)
156156
}
157157

158-
// WriteField calls CreateFormField and then writes the given value.
158+
// WriteField calls [Writer.CreateFormField] and then writes the given value.
159159
func (w *Writer) WriteField(fieldname, value string) error {
160160
p, err := w.CreateFormField(fieldname)
161161
if err != nil {

Diff for: src/mime/quotedprintable/writer.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import "io"
88

99
const lineMaxLen = 76
1010

11-
// A Writer is a quoted-printable writer that implements io.WriteCloser.
11+
// A Writer is a quoted-printable writer that implements [io.WriteCloser].
1212
type Writer struct {
1313
// Binary mode treats the writer's input as pure binary and processes end of
1414
// line bytes as binary data.
@@ -20,14 +20,14 @@ type Writer struct {
2020
cr bool
2121
}
2222

23-
// NewWriter returns a new Writer that writes to w.
23+
// NewWriter returns a new [Writer] that writes to w.
2424
func NewWriter(w io.Writer) *Writer {
2525
return &Writer{w: w}
2626
}
2727

2828
// Write encodes p using quoted-printable encoding and writes it to the
29-
// underlying io.Writer. It limits line length to 76 characters. The encoded
30-
// bytes are not necessarily flushed until the Writer is closed.
29+
// underlying [io.Writer]. It limits line length to 76 characters. The encoded
30+
// bytes are not necessarily flushed until the [Writer] is closed.
3131
func (w *Writer) Write(p []byte) (n int, err error) {
3232
for i, b := range p {
3333
switch {
@@ -62,8 +62,8 @@ func (w *Writer) Write(p []byte) (n int, err error) {
6262
return len(p), nil
6363
}
6464

65-
// Close closes the Writer, flushing any unwritten data to the underlying
66-
// io.Writer, but does not close the underlying io.Writer.
65+
// Close closes the [Writer], flushing any unwritten data to the underlying
66+
// [io.Writer], but does not close the underlying io.Writer.
6767
func (w *Writer) Close() error {
6868
if err := w.checkLastByte(); err != nil {
6969
return err

0 commit comments

Comments
 (0)