Thanks a lot for the powerful and detailed explanation, Dan. Though one surely needs to be careful when coding, I'm keeping my initial point to improve the document or any improvements like Robert suggested as below.
> developers shouldn’t have to read the code to understand the invariants of an api call. Lin On Fri, 21 Feb 2025 at 15:48, 'Dan Kortschak' via golang-nuts < golang-nuts@googlegroups.com> wrote: > On Fri, 2025-02-21 at 00:17 -0600, robert engels wrote: > > I think I disagree. The bnf you are quoting form is from “For > > example, some URI schemes do not allow an <authority> component, and > > others do not use a <query> component.” > > No. I part quoted the collected BNF. > https://datatracker.ietf.org/doc/html/rfc2396#appendix-A > > > The http scheme requires the //. > > I don't think you read what I wrote; yes, the http scheme does required > a host and so requires the "//", but, quoting myself, "The url.Parse > function doesn't examine semantics, that's the caller's > responsibility. The semantics here are clearly wrong, but it's up to > the caller to check and ensure that the passed value satisfies the > expectations." > > I think it's important to look at the documentation for url.Parse and > url.URL. Particularly this text: > > > A URL represents a parsed URL (technically, a URI reference). > > > > The general form represented is: > > > > [scheme:][//[userinfo@]host][/]path[?query][#fragment] > > > > URLs that do not start with a slash after the scheme are interpreted > > as: > > > > scheme:opaque[?query][#fragment] > > > > The Host field contains the host and port subcomponents of the URL. > > When the port is present, it is separated from the host with a colon. > > When the host is an IPv6 address, it must be enclosed in square > > brackets: "[fe80::1]:80". The net.JoinHostPort function combines a > > host and port into a string suitable for the Host field, adding > > square brackets to the host when necessary. > > > > Note that the Path field is stored in decoded form: /%47%6f%2f > > becomes /Go/. A consequence is that it is impossible to tell which > > slashes in the Path were slashes in the raw URL and which were %2f. > > This distinction is rarely important, but when it is, the code should > > use the URL.EscapedPath method, which preserves the original encoding > > of Path. > > > > The RawPath field is an optional field which is only set when the > > default encoding of Path is different from the escaped path. See the > > EscapedPath method for more details. > > > > URL's String method uses the EscapedPath method to obtain the path. > > This is consistent with the RFC. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion visit > https://groups.google.com/d/msgid/golang-nuts/fa5c37edec43169d9523eaca188761665fc0959c.camel%40kortschak.io > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CA%2BhP-7vPguRFMg2UmTKqe5VT4_PfC_%2Bphx8DOd_SSMjiF72vPw%40mail.gmail.com.