Skip to content

Commit 1d45a7e

Browse files
cuishuanggopherbot
authored andcommitted
net: add available godoc link
Change-Id: Ib7c4baf0247c421954aedabfbb6a6af8a08a8936 Reviewed-on: https://go-review.googlesource.com/c/go/+/540021 Reviewed-by: Damien Neil <[email protected]> Run-TryBot: shuang cui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent dcbe772 commit 1d45a7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+528
-528
lines changed

src/net/dial.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (m *mptcpStatus) set(use bool) {
6565
//
6666
// The zero value for each field is equivalent to dialing
6767
// without that option. Dialing with the zero value of Dialer
68-
// is therefore equivalent to just calling the Dial function.
68+
// is therefore equivalent to just calling the [Dial] function.
6969
//
7070
// It is safe to call Dialer's methods concurrently.
7171
type Dialer struct {
@@ -338,7 +338,7 @@ func (d *Dialer) MultipathTCP() bool {
338338
return d.mptcpStatus.get()
339339
}
340340

341-
// SetMultipathTCP directs the Dial methods to use, or not use, MPTCP,
341+
// SetMultipathTCP directs the [Dial] methods to use, or not use, MPTCP,
342342
// if supported by the operating system. This method overrides the
343343
// system default and the GODEBUG=multipathtcp=... setting if any.
344344
//
@@ -363,7 +363,7 @@ func (d *Dialer) SetMultipathTCP(use bool) {
363363
// brackets, as in "[2001:db8::1]:80" or "[fe80::1%zone]:80".
364364
// The zone specifies the scope of the literal IPv6 address as defined
365365
// in RFC 4007.
366-
// The functions JoinHostPort and SplitHostPort manipulate a pair of
366+
// The functions [JoinHostPort] and [SplitHostPort] manipulate a pair of
367367
// host and port in this form.
368368
// When using TCP, and the host resolves to multiple IP addresses,
369369
// Dial will try each IP address in order until one succeeds.
@@ -401,7 +401,7 @@ func Dial(network, address string) (Conn, error) {
401401
return d.Dial(network, address)
402402
}
403403

404-
// DialTimeout acts like Dial but takes a timeout.
404+
// DialTimeout acts like [Dial] but takes a timeout.
405405
//
406406
// The timeout includes name resolution, if required.
407407
// When using TCP, and the host in the address parameter resolves to
@@ -428,8 +428,8 @@ type sysDialer struct {
428428
// See func Dial for a description of the network and address
429429
// parameters.
430430
//
431-
// Dial uses context.Background internally; to specify the context, use
432-
// DialContext.
431+
// Dial uses [context.Background] internally; to specify the context, use
432+
// [Dialer.DialContext].
433433
func (d *Dialer) Dial(network, address string) (Conn, error) {
434434
return d.DialContext(context.Background(), network, address)
435435
}
@@ -450,7 +450,7 @@ func (d *Dialer) Dial(network, address string) (Conn, error) {
450450
// the connect to each single address will be given 15 seconds to complete
451451
// before trying the next one.
452452
//
453-
// See func Dial for a description of the network and address
453+
// See func [Dial] for a description of the network and address
454454
// parameters.
455455
func (d *Dialer) DialContext(ctx context.Context, network, address string) (Conn, error) {
456456
if ctx == nil {
@@ -700,7 +700,7 @@ func (lc *ListenConfig) MultipathTCP() bool {
700700
return lc.mptcpStatus.get()
701701
}
702702

703-
// SetMultipathTCP directs the Listen method to use, or not use, MPTCP,
703+
// SetMultipathTCP directs the [Listen] method to use, or not use, MPTCP,
704704
// if supported by the operating system. This method overrides the
705705
// system default and the GODEBUG=multipathtcp=... setting if any.
706706
//
@@ -795,14 +795,14 @@ type sysListener struct {
795795
// addresses.
796796
// If the port in the address parameter is empty or "0", as in
797797
// "127.0.0.1:" or "[::1]:0", a port number is automatically chosen.
798-
// The Addr method of Listener can be used to discover the chosen
798+
// The [Addr] method of [Listener] can be used to discover the chosen
799799
// port.
800800
//
801-
// See func Dial for a description of the network and address
801+
// See func [Dial] for a description of the network and address
802802
// parameters.
803803
//
804804
// Listen uses context.Background internally; to specify the context, use
805-
// ListenConfig.Listen.
805+
// [ListenConfig.Listen].
806806
func Listen(network, address string) (Listener, error) {
807807
var lc ListenConfig
808808
return lc.Listen(context.Background(), network, address)
@@ -825,14 +825,14 @@ func Listen(network, address string) (Listener, error) {
825825
// addresses.
826826
// If the port in the address parameter is empty or "0", as in
827827
// "127.0.0.1:" or "[::1]:0", a port number is automatically chosen.
828-
// The LocalAddr method of PacketConn can be used to discover the
828+
// The LocalAddr method of [PacketConn] can be used to discover the
829829
// chosen port.
830830
//
831-
// See func Dial for a description of the network and address
831+
// See func [Dial] for a description of the network and address
832832
// parameters.
833833
//
834834
// ListenPacket uses context.Background internally; to specify the context, use
835-
// ListenConfig.ListenPacket.
835+
// [ListenConfig.ListenPacket].
836836
func ListenPacket(network, address string) (PacketConn, error) {
837837
var lc ListenConfig
838838
return lc.ListenPacket(context.Background(), network, address)

src/net/http/cgi/child.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func envMap(env []string) map[string]string {
4646
return m
4747
}
4848

49-
// RequestFromMap creates an http.Request from CGI variables.
49+
// RequestFromMap creates an [http.Request] from CGI variables.
5050
// The returned Request's Body field is not populated.
5151
func RequestFromMap(params map[string]string) (*http.Request, error) {
5252
r := new(http.Request)
@@ -138,10 +138,10 @@ func RequestFromMap(params map[string]string) (*http.Request, error) {
138138
return r, nil
139139
}
140140

141-
// Serve executes the provided Handler on the currently active CGI
141+
// Serve executes the provided [Handler] on the currently active CGI
142142
// request, if any. If there's no current CGI environment
143143
// an error is returned. The provided handler may be nil to use
144-
// http.DefaultServeMux.
144+
// [http.DefaultServeMux].
145145
func Serve(handler http.Handler) error {
146146
req, err := Request()
147147
if err != nil {

src/net/http/client.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ import (
2727
"time"
2828
)
2929

30-
// A Client is an HTTP client. Its zero value (DefaultClient) is a
31-
// usable client that uses DefaultTransport.
30+
// A Client is an HTTP client. Its zero value ([DefaultClient]) is a
31+
// usable client that uses [DefaultTransport].
3232
//
33-
// The Client's Transport typically has internal state (cached TCP
33+
// The [Client.Transport] typically has internal state (cached TCP
3434
// connections), so Clients should be reused instead of created as
3535
// needed. Clients are safe for concurrent use by multiple goroutines.
3636
//
37-
// A Client is higher-level than a RoundTripper (such as Transport)
37+
// A Client is higher-level than a [RoundTripper] (such as [Transport])
3838
// and additionally handles HTTP details such as cookies and
3939
// redirects.
4040
//
4141
// When following redirects, the Client will forward all headers set on the
42-
// initial Request except:
42+
// initial [Request] except:
4343
//
4444
// - when forwarding sensitive headers like "Authorization",
4545
// "WWW-Authenticate", and "Cookie" to untrusted targets.
@@ -105,11 +105,11 @@ type Client struct {
105105
Timeout time.Duration
106106
}
107107

108-
// DefaultClient is the default Client and is used by Get, Head, and Post.
108+
// DefaultClient is the default [Client] and is used by [Get], [Head], and [Post].
109109
var DefaultClient = &Client{}
110110

111111
// RoundTripper is an interface representing the ability to execute a
112-
// single HTTP transaction, obtaining the Response for a given Request.
112+
// single HTTP transaction, obtaining the [Response] for a given [Request].
113113
//
114114
// A RoundTripper must be safe for concurrent use by multiple
115115
// goroutines.
@@ -439,45 +439,45 @@ func basicAuth(username, password string) string {
439439
//
440440
// An error is returned if there were too many redirects or if there
441441
// was an HTTP protocol error. A non-2xx response doesn't cause an
442-
// error. Any returned error will be of type *url.Error. The url.Error
442+
// error. Any returned error will be of type [*url.Error]. The url.Error
443443
// value's Timeout method will report true if the request timed out.
444444
//
445445
// When err is nil, resp always contains a non-nil resp.Body.
446446
// Caller should close resp.Body when done reading from it.
447447
//
448448
// Get is a wrapper around DefaultClient.Get.
449449
//
450-
// To make a request with custom headers, use NewRequest and
450+
// To make a request with custom headers, use [NewRequest] and
451451
// DefaultClient.Do.
452452
//
453-
// To make a request with a specified context.Context, use NewRequestWithContext
453+
// To make a request with a specified context.Context, use [NewRequestWithContext]
454454
// and DefaultClient.Do.
455455
func Get(url string) (resp *Response, err error) {
456456
return DefaultClient.Get(url)
457457
}
458458

459459
// Get issues a GET to the specified URL. If the response is one of the
460460
// following redirect codes, Get follows the redirect after calling the
461-
// Client's CheckRedirect function:
461+
// [Client.CheckRedirect] function:
462462
//
463463
// 301 (Moved Permanently)
464464
// 302 (Found)
465465
// 303 (See Other)
466466
// 307 (Temporary Redirect)
467467
// 308 (Permanent Redirect)
468468
//
469-
// An error is returned if the Client's CheckRedirect function fails
469+
// An error is returned if the [Client.CheckRedirect] function fails
470470
// or if there was an HTTP protocol error. A non-2xx response doesn't
471-
// cause an error. Any returned error will be of type *url.Error. The
471+
// cause an error. Any returned error will be of type [*url.Error]. The
472472
// url.Error value's Timeout method will report true if the request
473473
// timed out.
474474
//
475475
// When err is nil, resp always contains a non-nil resp.Body.
476476
// Caller should close resp.Body when done reading from it.
477477
//
478-
// To make a request with custom headers, use NewRequest and Client.Do.
478+
// To make a request with custom headers, use [NewRequest] and [Client.Do].
479479
//
480-
// To make a request with a specified context.Context, use NewRequestWithContext
480+
// To make a request with a specified context.Context, use [NewRequestWithContext]
481481
// and Client.Do.
482482
func (c *Client) Get(url string) (resp *Response, err error) {
483483
req, err := NewRequest("GET", url, nil)
@@ -558,10 +558,10 @@ func urlErrorOp(method string) string {
558558
// connectivity problem). A non-2xx status code doesn't cause an
559559
// error.
560560
//
561-
// If the returned error is nil, the Response will contain a non-nil
561+
// If the returned error is nil, the [Response] will contain a non-nil
562562
// Body which the user is expected to close. If the Body is not both
563-
// read to EOF and closed, the Client's underlying RoundTripper
564-
// (typically Transport) may not be able to re-use a persistent TCP
563+
// read to EOF and closed, the [Client]'s underlying [RoundTripper]
564+
// (typically [Transport]) may not be able to re-use a persistent TCP
565565
// connection to the server for a subsequent "keep-alive" request.
566566
//
567567
// The request Body, if non-nil, will be closed by the underlying
@@ -570,21 +570,21 @@ func urlErrorOp(method string) string {
570570
//
571571
// On error, any Response can be ignored. A non-nil Response with a
572572
// non-nil error only occurs when CheckRedirect fails, and even then
573-
// the returned Response.Body is already closed.
573+
// the returned [Response.Body] is already closed.
574574
//
575-
// Generally Get, Post, or PostForm will be used instead of Do.
575+
// Generally [Get], [Post], or [PostForm] will be used instead of Do.
576576
//
577577
// If the server replies with a redirect, the Client first uses the
578578
// CheckRedirect function to determine whether the redirect should be
579579
// followed. If permitted, a 301, 302, or 303 redirect causes
580580
// subsequent requests to use HTTP method GET
581581
// (or HEAD if the original request was HEAD), with no body.
582582
// A 307 or 308 redirect preserves the original HTTP method and body,
583-
// provided that the Request.GetBody function is defined.
584-
// The NewRequest function automatically sets GetBody for common
583+
// provided that the [Request.GetBody] function is defined.
584+
// The [NewRequest] function automatically sets GetBody for common
585585
// standard library body types.
586586
//
587-
// Any returned error will be of type *url.Error. The url.Error
587+
// Any returned error will be of type [*url.Error]. The url.Error
588588
// value's Timeout method will report true if the request timed out.
589589
func (c *Client) Do(req *Request) (*Response, error) {
590590
return c.do(req)
@@ -818,17 +818,17 @@ func defaultCheckRedirect(req *Request, via []*Request) error {
818818
//
819819
// Caller should close resp.Body when done reading from it.
820820
//
821-
// If the provided body is an io.Closer, it is closed after the
821+
// If the provided body is an [io.Closer], it is closed after the
822822
// request.
823823
//
824824
// Post is a wrapper around DefaultClient.Post.
825825
//
826-
// To set custom headers, use NewRequest and DefaultClient.Do.
826+
// To set custom headers, use [NewRequest] and DefaultClient.Do.
827827
//
828-
// See the Client.Do method documentation for details on how redirects
828+
// See the [Client.Do] method documentation for details on how redirects
829829
// are handled.
830830
//
831-
// To make a request with a specified context.Context, use NewRequestWithContext
831+
// To make a request with a specified context.Context, use [NewRequestWithContext]
832832
// and DefaultClient.Do.
833833
func Post(url, contentType string, body io.Reader) (resp *Response, err error) {
834834
return DefaultClient.Post(url, contentType, body)
@@ -838,13 +838,13 @@ func Post(url, contentType string, body io.Reader) (resp *Response, err error) {
838838
//
839839
// Caller should close resp.Body when done reading from it.
840840
//
841-
// If the provided body is an io.Closer, it is closed after the
841+
// If the provided body is an [io.Closer], it is closed after the
842842
// request.
843843
//
844-
// To set custom headers, use NewRequest and Client.Do.
844+
// To set custom headers, use [NewRequest] and [Client.Do].
845845
//
846-
// To make a request with a specified context.Context, use NewRequestWithContext
847-
// and Client.Do.
846+
// To make a request with a specified context.Context, use [NewRequestWithContext]
847+
// and [Client.Do].
848848
//
849849
// See the Client.Do method documentation for details on how redirects
850850
// are handled.
@@ -861,17 +861,17 @@ func (c *Client) Post(url, contentType string, body io.Reader) (resp *Response,
861861
// values URL-encoded as the request body.
862862
//
863863
// The Content-Type header is set to application/x-www-form-urlencoded.
864-
// To set other headers, use NewRequest and DefaultClient.Do.
864+
// To set other headers, use [NewRequest] and DefaultClient.Do.
865865
//
866866
// When err is nil, resp always contains a non-nil resp.Body.
867867
// Caller should close resp.Body when done reading from it.
868868
//
869869
// PostForm is a wrapper around DefaultClient.PostForm.
870870
//
871-
// See the Client.Do method documentation for details on how redirects
871+
// See the [Client.Do] method documentation for details on how redirects
872872
// are handled.
873873
//
874-
// To make a request with a specified context.Context, use NewRequestWithContext
874+
// To make a request with a specified [context.Context], use [NewRequestWithContext]
875875
// and DefaultClient.Do.
876876
func PostForm(url string, data url.Values) (resp *Response, err error) {
877877
return DefaultClient.PostForm(url, data)
@@ -881,15 +881,15 @@ func PostForm(url string, data url.Values) (resp *Response, err error) {
881881
// with data's keys and values URL-encoded as the request body.
882882
//
883883
// The Content-Type header is set to application/x-www-form-urlencoded.
884-
// To set other headers, use NewRequest and Client.Do.
884+
// To set other headers, use [NewRequest] and [Client.Do].
885885
//
886886
// When err is nil, resp always contains a non-nil resp.Body.
887887
// Caller should close resp.Body when done reading from it.
888888
//
889889
// See the Client.Do method documentation for details on how redirects
890890
// are handled.
891891
//
892-
// To make a request with a specified context.Context, use NewRequestWithContext
892+
// To make a request with a specified context.Context, use [NewRequestWithContext]
893893
// and Client.Do.
894894
func (c *Client) PostForm(url string, data url.Values) (resp *Response, err error) {
895895
return c.Post(url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
@@ -907,24 +907,24 @@ func (c *Client) PostForm(url string, data url.Values) (resp *Response, err erro
907907
//
908908
// Head is a wrapper around DefaultClient.Head.
909909
//
910-
// To make a request with a specified context.Context, use NewRequestWithContext
910+
// To make a request with a specified [context.Context], use [NewRequestWithContext]
911911
// and DefaultClient.Do.
912912
func Head(url string) (resp *Response, err error) {
913913
return DefaultClient.Head(url)
914914
}
915915

916916
// Head issues a HEAD to the specified URL. If the response is one of the
917917
// following redirect codes, Head follows the redirect after calling the
918-
// Client's CheckRedirect function:
918+
// [Client.CheckRedirect] function:
919919
//
920920
// 301 (Moved Permanently)
921921
// 302 (Found)
922922
// 303 (See Other)
923923
// 307 (Temporary Redirect)
924924
// 308 (Permanent Redirect)
925925
//
926-
// To make a request with a specified context.Context, use NewRequestWithContext
927-
// and Client.Do.
926+
// To make a request with a specified [context.Context], use [NewRequestWithContext]
927+
// and [Client.Do].
928928
func (c *Client) Head(url string) (resp *Response, err error) {
929929
req, err := NewRequest("HEAD", url, nil)
930930
if err != nil {
@@ -933,12 +933,12 @@ func (c *Client) Head(url string) (resp *Response, err error) {
933933
return c.Do(req)
934934
}
935935

936-
// CloseIdleConnections closes any connections on its Transport which
936+
// CloseIdleConnections closes any connections on its [Transport] which
937937
// were previously connected from previous requests but are now
938938
// sitting idle in a "keep-alive" state. It does not interrupt any
939939
// connections currently in use.
940940
//
941-
// If the Client's Transport does not have a CloseIdleConnections method
941+
// If [Client.Transport] does not have a [Client.CloseIdleConnections] method
942942
// then this method does nothing.
943943
func (c *Client) CloseIdleConnections() {
944944
type closeIdler interface {

src/net/http/cookie.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func readSetCookies(h Header) []*Cookie {
163163
return cookies
164164
}
165165

166-
// SetCookie adds a Set-Cookie header to the provided ResponseWriter's headers.
166+
// SetCookie adds a Set-Cookie header to the provided [ResponseWriter]'s headers.
167167
// The provided cookie must have a valid Name. Invalid cookies may be
168168
// silently dropped.
169169
func SetCookie(w ResponseWriter, cookie *Cookie) {
@@ -172,7 +172,7 @@ func SetCookie(w ResponseWriter, cookie *Cookie) {
172172
}
173173
}
174174

175-
// String returns the serialization of the cookie for use in a Cookie
175+
// String returns the serialization of the cookie for use in a [Cookie]
176176
// header (if only Name and Value are set) or a Set-Cookie response
177177
// header (if other fields are set).
178178
// If c is nil or c.Name is invalid, the empty string is returned.

0 commit comments

Comments
 (0)