From 290c469a71a567d354e4abd335577aba44c4bde4 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 11 Apr 2022 13:11:24 -0400 Subject: [PATCH] all: gofmt Gofmt to update doc comments to the new formatting. For golang/go#51082. Change-Id: Iae68a9cd600060577271575e893ecb23bed1e509 Reviewed-on: https://go-review.googlesource.com/c/net/+/399599 Run-TryBot: Russ Cox Reviewed-by: Ian Lance Taylor Auto-Submit: Russ Cox TryBot-Result: Gopher Robot --- bpf/doc.go | 6 +-- context/context.go | 6 +-- context/go17.go | 10 ++-- context/pre_go17.go | 10 ++-- dns/dnsmessage/message.go | 1 + http/httpguts/httplex.go | 54 +++++++++++---------- http2/h2i/h2i.go | 11 +++-- http2/http2.go | 14 +++--- http2/server.go | 5 +- http2/server_test.go | 5 +- http2/transport_test.go | 9 ++-- icmp/listen_posix.go | 2 + icmp/listen_stub.go | 2 + idna/trieval.go | 34 ++++++------- internal/socket/zsys_linux_ppc.go | 32 ++++++------ ipv4/doc.go | 12 ++--- ipv6/doc.go | 12 ++--- publicsuffix/list.go | 7 +-- publicsuffix/table.go | 2 + webdav/file.go | 1 + webdav/internal/xml/marshal.go | 48 +++++++++--------- webdav/internal/xml/read.go | 81 +++++++++++++++---------------- webdav/lock_test.go | 6 +-- webdav/webdav.go | 9 ++-- webdav/xml_test.go | 17 +++---- websocket/websocket.go | 5 +- 26 files changed, 204 insertions(+), 197 deletions(-) diff --git a/bpf/doc.go b/bpf/doc.go index ae62feb53..04ec1c8ab 100644 --- a/bpf/doc.go +++ b/bpf/doc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. /* - Package bpf implements marshaling and unmarshaling of programs for the Berkeley Packet Filter virtual machine, and provides a Go implementation of the virtual machine. @@ -21,7 +20,7 @@ access to kernel functions, and while conditional branches are allowed, they can only jump forwards, to guarantee that there are no infinite loops. -The virtual machine +# The virtual machine The BPF VM is an accumulator machine. Its main register, called register A, is an implicit source and destination in all arithmetic @@ -50,7 +49,7 @@ to extensions, which are essentially calls to kernel utility functions. Currently, the only extensions supported by this package are the Linux packet filter extensions. -Examples +# Examples This packet filter selects all ARP packets. @@ -77,6 +76,5 @@ This packet filter captures a random 1% sample of traffic. // Ignore. bpf.RetConstant{Val: 0}, }) - */ package bpf // import "golang.org/x/net/bpf" diff --git a/context/context.go b/context/context.go index a3c021d3f..cf66309c4 100644 --- a/context/context.go +++ b/context/context.go @@ -21,9 +21,9 @@ // explicitly to each function that needs it. The Context should be the first // parameter, typically named ctx: // -// func DoSomething(ctx context.Context, arg Arg) error { -// // ... use ctx ... -// } +// func DoSomething(ctx context.Context, arg Arg) error { +// // ... use ctx ... +// } // // Do not pass a nil Context, even if a function permits it. Pass context.TODO // if you are unsure about which Context to use. diff --git a/context/go17.go b/context/go17.go index 344bd1433..0a54bdbcc 100644 --- a/context/go17.go +++ b/context/go17.go @@ -54,11 +54,11 @@ func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { // Canceling this context releases resources associated with it, so code should // call cancel as soon as the operations running in this Context complete: // -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } +// func slowOperationWithTimeout(ctx context.Context) (Result, error) { +// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) +// defer cancel() // releases resources if slowOperation completes before timeout elapses +// return slowOperation(ctx) +// } func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { return WithDeadline(parent, time.Now().Add(timeout)) } diff --git a/context/pre_go17.go b/context/pre_go17.go index 5270db5db..7b6b68511 100644 --- a/context/pre_go17.go +++ b/context/pre_go17.go @@ -264,11 +264,11 @@ func (c *timerCtx) cancel(removeFromParent bool, err error) { // Canceling this context releases resources associated with it, so code should // call cancel as soon as the operations running in this Context complete: // -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } +// func slowOperationWithTimeout(ctx context.Context) (Result, error) { +// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) +// defer cancel() // releases resources if slowOperation completes before timeout elapses +// return slowOperation(ctx) +// } func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { return WithDeadline(parent, time.Now().Add(timeout)) } diff --git a/dns/dnsmessage/message.go b/dns/dnsmessage/message.go index 8c24430c5..0cdf89f9f 100644 --- a/dns/dnsmessage/message.go +++ b/dns/dnsmessage/message.go @@ -1173,6 +1173,7 @@ func (m *Message) GoString() string { // A Builder allows incrementally packing a DNS message. // // Example usage: +// // buf := make([]byte, 2, 514) // b := NewBuilder(buf, Header{...}) // b.EnableCompression() diff --git a/http/httpguts/httplex.go b/http/httpguts/httplex.go index c79aa73f2..6e071e852 100644 --- a/http/httpguts/httplex.go +++ b/http/httpguts/httplex.go @@ -173,13 +173,15 @@ func tokenEqual(t1, t2 string) bool { // isLWS reports whether b is linear white space, according // to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 -// LWS = [CRLF] 1*( SP | HT ) +// +// LWS = [CRLF] 1*( SP | HT ) func isLWS(b byte) bool { return b == ' ' || b == '\t' } // isCTL reports whether b is a control byte, according // to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 -// CTL = +// +// CTL = func isCTL(b byte) bool { const del = 0x7f // a CTL return b < ' ' || b == del @@ -189,12 +191,13 @@ func isCTL(b byte) bool { // HTTP/2 imposes the additional restriction that uppercase ASCII // letters are not allowed. // -// RFC 7230 says: -// header-field = field-name ":" OWS field-value OWS -// field-name = token -// token = 1*tchar -// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / -// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA +// RFC 7230 says: +// +// header-field = field-name ":" OWS field-value OWS +// field-name = token +// token = 1*tchar +// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / +// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA func ValidHeaderFieldName(v string) bool { if len(v) == 0 { return false @@ -267,27 +270,28 @@ var validHostByte = [256]bool{ // ValidHeaderFieldValue reports whether v is a valid "field-value" according to // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 : // -// message-header = field-name ":" [ field-value ] -// field-value = *( field-content | LWS ) -// field-content = +// message-header = field-name ":" [ field-value ] +// field-value = *( field-content | LWS ) +// field-content = // // http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 : // -// TEXT = -// LWS = [CRLF] 1*( SP | HT ) -// CTL = +// TEXT = +// LWS = [CRLF] 1*( SP | HT ) +// CTL = // // RFC 7230 says: -// field-value = *( field-content / obs-fold ) -// obj-fold = N/A to http2, and deprecated -// field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] -// field-vchar = VCHAR / obs-text -// obs-text = %x80-FF -// VCHAR = "any visible [USASCII] character" +// +// field-value = *( field-content / obs-fold ) +// obj-fold = N/A to http2, and deprecated +// field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] +// field-vchar = VCHAR / obs-text +// obs-text = %x80-FF +// VCHAR = "any visible [USASCII] character" // // http2 further says: "Similarly, HTTP/2 allows header field values // that are not valid. While most of the values that can be encoded diff --git a/http2/h2i/h2i.go b/http2/h2i/h2i.go index 4fa243f0b..901f6ca79 100644 --- a/http2/h2i/h2i.go +++ b/http2/h2i/h2i.go @@ -9,14 +9,15 @@ The h2i command is an interactive HTTP/2 console. Usage: - $ h2i [flags] + + $ h2i [flags] Interactive commands in the console: (all parts case-insensitive) - ping [data] - settings ack - settings FOO=n BAR=z - headers (open a new stream by typing HTTP/1.1) + ping [data] + settings ack + settings FOO=n BAR=z + headers (open a new stream by typing HTTP/1.1) */ package main diff --git a/http2/http2.go b/http2/http2.go index 5571ccfd2..479ba4b2b 100644 --- a/http2/http2.go +++ b/http2/http2.go @@ -13,7 +13,6 @@ // See https://http2.github.io/ for more information on HTTP/2. // // See https://http2.golang.org/ for a test server running this code. -// package http2 // import "golang.org/x/net/http2" import ( @@ -176,10 +175,11 @@ func (s SettingID) String() string { // name (key). See httpguts.ValidHeaderName for the base rules. // // Further, http2 says: -// "Just as in HTTP/1.x, header field names are strings of ASCII -// characters that are compared in a case-insensitive -// fashion. However, header field names MUST be converted to -// lowercase prior to their encoding in HTTP/2. " +// +// "Just as in HTTP/1.x, header field names are strings of ASCII +// characters that are compared in a case-insensitive +// fashion. However, header field names MUST be converted to +// lowercase prior to their encoding in HTTP/2. " func validWireHeaderFieldName(v string) bool { if len(v) == 0 { return false @@ -365,8 +365,8 @@ func (s *sorter) SortStrings(ss []string) { // validPseudoPath reports whether v is a valid :path pseudo-header // value. It must be either: // -// *) a non-empty string starting with '/' -// *) the string '*', for OPTIONS requests. +// - a non-empty string starting with '/' +// - the string '*', for OPTIONS requests. // // For now this is only used a quick check for deciding when to clean // up Opaque URLs before sending requests from the Transport. diff --git a/http2/server.go b/http2/server.go index e644d9b2f..33765d3a6 100644 --- a/http2/server.go +++ b/http2/server.go @@ -2546,8 +2546,9 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { // prior to the headers being written. If the set of trailers is fixed // or known before the header is written, the normal Go trailers mechanism // is preferred: -// https://golang.org/pkg/net/http/#ResponseWriter -// https://golang.org/pkg/net/http/#example_ResponseWriter_trailers +// +// https://golang.org/pkg/net/http/#ResponseWriter +// https://golang.org/pkg/net/http/#example_ResponseWriter_trailers const TrailerPrefix = "Trailer:" // promoteUndeclaredTrailers permits http.Handlers to set trailers diff --git a/http2/server_test.go b/http2/server_test.go index a1b1b2b91..46ac6ee25 100644 --- a/http2/server_test.go +++ b/http2/server_test.go @@ -2702,8 +2702,9 @@ func readBodyHandler(t *testing.T, want string) func(w http.ResponseWriter, r *h } // TestServerWithCurl currently fails, hence the LenientCipherSuites test. See: -// https://github.com/tatsuhiro-t/nghttp2/issues/140 & -// http://sourceforge.net/p/curl/bugs/1472/ +// +// https://github.com/tatsuhiro-t/nghttp2/issues/140 & +// http://sourceforge.net/p/curl/bugs/1472/ func TestServerWithCurl(t *testing.T) { testServerWithCurl(t, false) } func TestServerWithCurl_LenientCipherSuites(t *testing.T) { testServerWithCurl(t, true) } diff --git a/http2/transport_test.go b/http2/transport_test.go index 030cbe9f1..c027255ef 100644 --- a/http2/transport_test.go +++ b/http2/transport_test.go @@ -1155,7 +1155,9 @@ const ( ) // Test all 36 combinations of response frame orders: -// (3 ways of 100-continue) * (2 ways of headers) * (2 ways of data) * (3 ways of trailers):func TestTransportResponsePattern_00f0(t *testing.T) { testTransportResponsePattern(h0, h1, false, h0) } +// +// (3 ways of 100-continue) * (2 ways of headers) * (2 ways of data) * (3 ways of trailers):func TestTransportResponsePattern_00f0(t *testing.T) { testTransportResponsePattern(h0, h1, false, h0) } +// // Generated by http://play.golang.org/p/SScqYKJYXd func TestTransportResPattern_c0h1d0t0(t *testing.T) { testTransportResPattern(t, f0, f1, d0, f0) } func TestTransportResPattern_c0h1d0t1(t *testing.T) { testTransportResPattern(t, f0, f1, d0, f1) } @@ -1575,8 +1577,9 @@ func testInvalidTrailer(t *testing.T, trailers headerType, wantErr error, writeT } // headerListSize returns the HTTP2 header list size of h. -// http://httpwg.org/specs/rfc7540.html#SETTINGS_MAX_HEADER_LIST_SIZE -// http://httpwg.org/specs/rfc7540.html#MaxHeaderBlock +// +// http://httpwg.org/specs/rfc7540.html#SETTINGS_MAX_HEADER_LIST_SIZE +// http://httpwg.org/specs/rfc7540.html#MaxHeaderBlock func headerListSize(h http.Header) (size uint32) { for k, vv := range h { for _, v := range vv { diff --git a/icmp/listen_posix.go b/icmp/listen_posix.go index bcad739bf..6aea80478 100644 --- a/icmp/listen_posix.go +++ b/icmp/listen_posix.go @@ -29,6 +29,7 @@ const sysIP_STRIPHDR = 0x17 // for now only darwin supports this option // Currently only Darwin and Linux support this. // // Examples: +// // ListenPacket("udp4", "192.168.0.1") // ListenPacket("udp4", "0.0.0.0") // ListenPacket("udp6", "fe80::1%en0") @@ -38,6 +39,7 @@ const sysIP_STRIPHDR = 0x17 // for now only darwin supports this option // followed by a colon and an ICMP protocol number or name. // // Examples: +// // ListenPacket("ip4:icmp", "192.168.0.1") // ListenPacket("ip4:1", "0.0.0.0") // ListenPacket("ip6:ipv6-icmp", "fe80::1%en0") diff --git a/icmp/listen_stub.go b/icmp/listen_stub.go index bc9343c4f..1acfb74b6 100644 --- a/icmp/listen_stub.go +++ b/icmp/listen_stub.go @@ -16,6 +16,7 @@ package icmp // Currently only Darwin and Linux support this. // // Examples: +// // ListenPacket("udp4", "192.168.0.1") // ListenPacket("udp4", "0.0.0.0") // ListenPacket("udp6", "fe80::1%en0") @@ -25,6 +26,7 @@ package icmp // followed by a colon and an ICMP protocol number or name. // // Examples: +// // ListenPacket("ip4:icmp", "192.168.0.1") // ListenPacket("ip4:1", "0.0.0.0") // ListenPacket("ip6:ipv6-icmp", "fe80::1%en0") diff --git a/idna/trieval.go b/idna/trieval.go index 7a8cf889b..9c070a44b 100644 --- a/idna/trieval.go +++ b/idna/trieval.go @@ -17,23 +17,23 @@ package idna // // The per-rune values have the following format: // -// if mapped { -// if inlinedXOR { -// 15..13 inline XOR marker -// 12..11 unused -// 10..3 inline XOR mask -// } else { -// 15..3 index into xor or mapping table -// } -// } else { -// 15..14 unused -// 13 mayNeedNorm -// 12..11 attributes -// 10..8 joining type -// 7..3 category type -// } -// 2 use xor pattern -// 1..0 mapped category +// if mapped { +// if inlinedXOR { +// 15..13 inline XOR marker +// 12..11 unused +// 10..3 inline XOR mask +// } else { +// 15..3 index into xor or mapping table +// } +// } else { +// 15..14 unused +// 13 mayNeedNorm +// 12..11 attributes +// 10..8 joining type +// 7..3 category type +// } +// 2 use xor pattern +// 1..0 mapped category // // See the definitions below for a more detailed description of the various // bits. diff --git a/internal/socket/zsys_linux_ppc.go b/internal/socket/zsys_linux_ppc.go index 59b71da57..4c19269be 100644 --- a/internal/socket/zsys_linux_ppc.go +++ b/internal/socket/zsys_linux_ppc.go @@ -4,32 +4,32 @@ package socket type iovec struct { - Base *byte - Len uint32 + Base *byte + Len uint32 } type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen uint32 - Control *byte - Controllen uint32 - Flags int32 + Name *byte + Namelen uint32 + Iov *iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 } type mmsghdr struct { - Hdr msghdr - Len uint32 + Hdr msghdr + Len uint32 } type cmsghdr struct { - Len uint32 - Level int32 - Type int32 + Len uint32 + Level int32 + Type int32 } const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c + sizeofIovec = 0x8 + sizeofMsghdr = 0x1c ) diff --git a/ipv4/doc.go b/ipv4/doc.go index 245834979..6fbdc52b9 100644 --- a/ipv4/doc.go +++ b/ipv4/doc.go @@ -16,8 +16,7 @@ // 3376. // Source-specific multicast is defined in RFC 4607. // -// -// Unicasting +// # Unicasting // // The options for unicasting are available for net.TCPConn, // net.UDPConn and net.IPConn which are created as network connections @@ -51,8 +50,7 @@ // }(c) // } // -// -// Multicasting +// # Multicasting // // The options for multicasting are available for net.UDPConn and // net.IPConn which are created as network connections that use the @@ -141,8 +139,7 @@ // } // } // -// -// More multicasting +// # More multicasting // // An application that uses PacketConn or RawConn may join multiple // multicast groups. For example, a UDP listener with port 1024 might @@ -200,8 +197,7 @@ // // error handling // } // -// -// Source-specific multicasting +// # Source-specific multicasting // // An application that uses PacketConn or RawConn on IGMPv3 supported // platform is able to join source-specific multicast groups. diff --git a/ipv6/doc.go b/ipv6/doc.go index e0be9d50d..2148b814f 100644 --- a/ipv6/doc.go +++ b/ipv6/doc.go @@ -17,8 +17,7 @@ // On Darwin, this package requires OS X Mavericks version 10.9 or // above, or equivalent. // -// -// Unicasting +// # Unicasting // // The options for unicasting are available for net.TCPConn, // net.UDPConn and net.IPConn which are created as network connections @@ -52,8 +51,7 @@ // }(c) // } // -// -// Multicasting +// # Multicasting // // The options for multicasting are available for net.UDPConn and // net.IPConn which are created as network connections that use the @@ -140,8 +138,7 @@ // } // } // -// -// More multicasting +// # More multicasting // // An application that uses PacketConn may join multiple multicast // groups. For example, a UDP listener with port 1024 might join two @@ -199,8 +196,7 @@ // // error handling // } // -// -// Source-specific multicasting +// # Source-specific multicasting // // An application that uses PacketConn on MLDv2 supported platform is // able to join source-specific multicast groups. diff --git a/publicsuffix/list.go b/publicsuffix/list.go index 200617ea8..e2fddd645 100644 --- a/publicsuffix/list.go +++ b/publicsuffix/list.go @@ -33,9 +33,10 @@ // the last two are not (but share the same eTLD+1: "google.com"). // // All of these domains have the same eTLD+1: -// - "www.books.amazon.co.uk" -// - "books.amazon.co.uk" -// - "amazon.co.uk" +// - "www.books.amazon.co.uk" +// - "books.amazon.co.uk" +// - "amazon.co.uk" +// // Specifically, the eTLD+1 is "amazon.co.uk", because the eTLD is "co.uk". // // There is no closed form algorithm to calculate the eTLD of a domain. diff --git a/publicsuffix/table.go b/publicsuffix/table.go index fd3c3ca48..a44423976 100644 --- a/publicsuffix/table.go +++ b/publicsuffix/table.go @@ -540,6 +540,7 @@ const text = "9guacuiababia-goracleaningroks-theatree164-balsfjordd-dnshome-we" // An I denotes an ICANN domain. // // The layout within the uint32, from MSB to LSB, is: +// // [ 0 bits] unused // [10 bits] children index // [ 1 bits] ICANN bit @@ -9898,6 +9899,7 @@ var nodes = [...]uint32{ // will be in the range [0, 6), depending on the wildcard bit and node type. // // The layout within the uint32, from MSB to LSB, is: +// // [ 1 bits] unused // [ 1 bits] wildcard bit // [ 2 bits] node type diff --git a/webdav/file.go b/webdav/file.go index 3fcc05394..c48a17e90 100644 --- a/webdav/file.go +++ b/webdav/file.go @@ -163,6 +163,7 @@ type memFS struct { // - "/", "foo", false // - "/foo/", "bar", false // - "/foo/bar/", "x", true +// // The frag argument will be empty only if dir is the root node and the walk // ends at that root node. func (fs *memFS) walk(op, fullname string, f func(dir *memFSNode, frag string, final bool) error) error { diff --git a/webdav/internal/xml/marshal.go b/webdav/internal/xml/marshal.go index cb82ec214..4dd0f417f 100644 --- a/webdav/internal/xml/marshal.go +++ b/webdav/internal/xml/marshal.go @@ -32,33 +32,33 @@ const ( // elements containing the data. // // The name for the XML elements is taken from, in order of preference: -// - the tag on the XMLName field, if the data is a struct -// - the value of the XMLName field of type xml.Name -// - the tag of the struct field used to obtain the data -// - the name of the struct field used to obtain the data -// - the name of the marshalled type +// - the tag on the XMLName field, if the data is a struct +// - the value of the XMLName field of type xml.Name +// - the tag of the struct field used to obtain the data +// - the name of the struct field used to obtain the data +// - the name of the marshalled type // // The XML element for a struct contains marshalled elements for each of the // exported fields of the struct, with these exceptions: -// - the XMLName field, described above, is omitted. -// - a field with tag "-" is omitted. -// - a field with tag "name,attr" becomes an attribute with -// the given name in the XML element. -// - a field with tag ",attr" becomes an attribute with the -// field name in the XML element. -// - a field with tag ",chardata" is written as character data, -// not as an XML element. -// - a field with tag ",innerxml" is written verbatim, not subject -// to the usual marshalling procedure. -// - a field with tag ",comment" is written as an XML comment, not -// subject to the usual marshalling procedure. It must not contain -// the "--" string within it. -// - a field with a tag including the "omitempty" option is omitted -// if the field value is empty. The empty values are false, 0, any -// nil pointer or interface value, and any array, slice, map, or -// string of length zero. -// - an anonymous struct field is handled as if the fields of its -// value were part of the outer struct. +// - the XMLName field, described above, is omitted. +// - a field with tag "-" is omitted. +// - a field with tag "name,attr" becomes an attribute with +// the given name in the XML element. +// - a field with tag ",attr" becomes an attribute with the +// field name in the XML element. +// - a field with tag ",chardata" is written as character data, +// not as an XML element. +// - a field with tag ",innerxml" is written verbatim, not subject +// to the usual marshalling procedure. +// - a field with tag ",comment" is written as an XML comment, not +// subject to the usual marshalling procedure. It must not contain +// the "--" string within it. +// - a field with a tag including the "omitempty" option is omitted +// if the field value is empty. The empty values are false, 0, any +// nil pointer or interface value, and any array, slice, map, or +// string of length zero. +// - an anonymous struct field is handled as if the fields of its +// value were part of the outer struct. // // If a field uses a tag "a>b>c", then the element c will be nested inside // parent elements a and b. Fields that appear next to each other that name diff --git a/webdav/internal/xml/read.go b/webdav/internal/xml/read.go index 4089056a1..bfaef6f17 100644 --- a/webdav/internal/xml/read.go +++ b/webdav/internal/xml/read.go @@ -35,57 +35,57 @@ import ( // In the rules, the tag of a field refers to the value associated with the // key 'xml' in the struct field's tag (see the example above). // -// * If the struct has a field of type []byte or string with tag -// ",innerxml", Unmarshal accumulates the raw XML nested inside the -// element in that field. The rest of the rules still apply. +// - If the struct has a field of type []byte or string with tag +// ",innerxml", Unmarshal accumulates the raw XML nested inside the +// element in that field. The rest of the rules still apply. // -// * If the struct has a field named XMLName of type xml.Name, -// Unmarshal records the element name in that field. +// - If the struct has a field named XMLName of type xml.Name, +// Unmarshal records the element name in that field. // -// * If the XMLName field has an associated tag of the form -// "name" or "namespace-URL name", the XML element must have -// the given name (and, optionally, name space) or else Unmarshal -// returns an error. +// - If the XMLName field has an associated tag of the form +// "name" or "namespace-URL name", the XML element must have +// the given name (and, optionally, name space) or else Unmarshal +// returns an error. // -// * If the XML element has an attribute whose name matches a -// struct field name with an associated tag containing ",attr" or -// the explicit name in a struct field tag of the form "name,attr", -// Unmarshal records the attribute value in that field. +// - If the XML element has an attribute whose name matches a +// struct field name with an associated tag containing ",attr" or +// the explicit name in a struct field tag of the form "name,attr", +// Unmarshal records the attribute value in that field. // -// * If the XML element contains character data, that data is -// accumulated in the first struct field that has tag ",chardata". -// The struct field may have type []byte or string. -// If there is no such field, the character data is discarded. +// - If the XML element contains character data, that data is +// accumulated in the first struct field that has tag ",chardata". +// The struct field may have type []byte or string. +// If there is no such field, the character data is discarded. // -// * If the XML element contains comments, they are accumulated in -// the first struct field that has tag ",comment". The struct -// field may have type []byte or string. If there is no such -// field, the comments are discarded. +// - If the XML element contains comments, they are accumulated in +// the first struct field that has tag ",comment". The struct +// field may have type []byte or string. If there is no such +// field, the comments are discarded. // -// * If the XML element contains a sub-element whose name matches -// the prefix of a tag formatted as "a" or "a>b>c", unmarshal -// will descend into the XML structure looking for elements with the -// given names, and will map the innermost elements to that struct -// field. A tag starting with ">" is equivalent to one starting -// with the field name followed by ">". +// - If the XML element contains a sub-element whose name matches +// the prefix of a tag formatted as "a" or "a>b>c", unmarshal +// will descend into the XML structure looking for elements with the +// given names, and will map the innermost elements to that struct +// field. A tag starting with ">" is equivalent to one starting +// with the field name followed by ">". // -// * If the XML element contains a sub-element whose name matches -// a struct field's XMLName tag and the struct field has no -// explicit name tag as per the previous rule, unmarshal maps -// the sub-element to that struct field. +// - If the XML element contains a sub-element whose name matches +// a struct field's XMLName tag and the struct field has no +// explicit name tag as per the previous rule, unmarshal maps +// the sub-element to that struct field. // -// * If the XML element contains a sub-element whose name matches a -// field without any mode flags (",attr", ",chardata", etc), Unmarshal -// maps the sub-element to that struct field. +// - If the XML element contains a sub-element whose name matches a +// field without any mode flags (",attr", ",chardata", etc), Unmarshal +// maps the sub-element to that struct field. // -// * If the XML element contains a sub-element that hasn't matched any -// of the above rules and the struct has a field with tag ",any", -// unmarshal maps the sub-element to that struct field. +// - If the XML element contains a sub-element that hasn't matched any +// of the above rules and the struct has a field with tag ",any", +// unmarshal maps the sub-element to that struct field. // -// * An anonymous struct field is handled as if the fields of its -// value were part of the outer struct. +// - An anonymous struct field is handled as if the fields of its +// value were part of the outer struct. // -// * A struct field with tag "-" is never unmarshalled into. +// - A struct field with tag "-" is never unmarshalled into. // // Unmarshal maps an XML element to a string or []byte by saving the // concatenation of that element's character data in the string or @@ -110,7 +110,6 @@ import ( // // Unmarshal maps an XML element to a pointer by setting the pointer // to a freshly allocated value and then mapping the element to that value. -// func Unmarshal(data []byte, v interface{}) error { return NewDecoder(bytes.NewReader(data)).Decode(v) } diff --git a/webdav/lock_test.go b/webdav/lock_test.go index 561ada4ed..e7fe97061 100644 --- a/webdav/lock_test.go +++ b/webdav/lock_test.go @@ -68,9 +68,9 @@ var lockTestDurations = []time.Duration{ // lockTestNames are the names of a set of mutually compatible locks. For each // name fragment: -// - _ means no explicit lock. -// - i means an infinite-depth lock, -// - z means a zero-depth lock, +// - _ means no explicit lock. +// - i means an infinite-depth lock, +// - z means a zero-depth lock, var lockTestNames = []string{ "/_/_/_/_/z", "/_/_/i", diff --git a/webdav/webdav.go b/webdav/webdav.go index d88995f9f..32f5b6579 100644 --- a/webdav/webdav.go +++ b/webdav/webdav.go @@ -642,10 +642,11 @@ const ( // infiniteDepth. Parsing any other string returns invalidDepth. // // Different WebDAV methods have further constraints on valid depths: -// - PROPFIND has no further restrictions, as per section 9.1. -// - COPY accepts only "0" or "infinity", as per section 9.8.3. -// - MOVE accepts only "infinity", as per section 9.9.2. -// - LOCK accepts only "0" or "infinity", as per section 9.10.3. +// - PROPFIND has no further restrictions, as per section 9.1. +// - COPY accepts only "0" or "infinity", as per section 9.8.3. +// - MOVE accepts only "infinity", as per section 9.9.2. +// - LOCK accepts only "0" or "infinity", as per section 9.10.3. +// // These constraints are enforced by the handleXxx methods. func parseDepth(s string) int { switch s { diff --git a/webdav/xml_test.go b/webdav/xml_test.go index a3d9e1ed8..ac2f247c9 100644 --- a/webdav/xml_test.go +++ b/webdav/xml_test.go @@ -827,15 +827,14 @@ type xmlNormalizer struct { // normalize writes the normalized XML content of r to w. It applies the // following rules // -// * Rename namespace prefixes according to an internal heuristic. -// * Remove unnecessary namespace declarations. -// * Sort attributes in XML start elements in lexical order of their -// fully qualified name. -// * Remove XML directives and processing instructions. -// * Remove CDATA between XML tags that only contains whitespace, if -// instructed to do so. -// * Remove comments, if instructed to do so. -// +// - Rename namespace prefixes according to an internal heuristic. +// - Remove unnecessary namespace declarations. +// - Sort attributes in XML start elements in lexical order of their +// fully qualified name. +// - Remove XML directives and processing instructions. +// - Remove CDATA between XML tags that only contains whitespace, if +// instructed to do so. +// - Remove comments, if instructed to do so. func (n *xmlNormalizer) normalize(w io.Writer, r io.Reader) error { d := ixml.NewDecoder(r) e := ixml.NewEncoder(w) diff --git a/websocket/websocket.go b/websocket/websocket.go index 6c45c7352..ea422e110 100644 --- a/websocket/websocket.go +++ b/websocket/websocket.go @@ -8,8 +8,8 @@ // This package currently lacks some features found in alternative // and more actively maintained WebSocket packages: // -// https://godoc.org/github.com/gorilla/websocket -// https://godoc.org/nhooyr.io/websocket +// https://godoc.org/github.com/gorilla/websocket +// https://godoc.org/nhooyr.io/websocket package websocket // import "golang.org/x/net/websocket" import ( @@ -416,7 +416,6 @@ Trivial usage: // send binary frame data = []byte{0, 1, 2} websocket.Message.Send(ws, data) - */ var Message = Codec{marshal, unmarshal}