[go] net/url: fix some typos

29 views
Skip to first unread message

Emmanuel Odeke (Gerrit)

unread,
Apr 1, 2021, 1:43:29 AM4/1/21
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go Bot, Ian Lance Taylor, Cluas, Baokun Lee, golang-co...@googlegroups.com

Emmanuel Odeke submitted this change.

View Change

Approvals: Ian Lance Taylor: Looks good to me, approved Emmanuel Odeke: Trusted; Run TryBots Go Bot: TryBots succeeded
net/url: use camelCase names

Change-Id: I191b98b846c9de58b1892e695058c727402b5400
GitHub-Last-Rev: f241ddd96b4e847ee3608133a41e1b2bb553982d
GitHub-Pull-Request: golang/go#45291
Reviewed-on: https://go-review.googlesource.com/c/go/+/305770
Trust: Emmanuel Odeke <emma...@orijtech.com>
Run-TryBot: Emmanuel Odeke <emma...@orijtech.com>
TryBot-Result: Go Bot <go...@golang.org>
Reviewed-by: Ian Lance Taylor <ia...@golang.org>
---
M src/net/url/url.go
1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/net/url/url.go b/src/net/url/url.go
index d90f5f0..e138082 100644
--- a/src/net/url/url.go
+++ b/src/net/url/url.go
@@ -425,31 +425,31 @@
return s
}

-// Maybe rawurl is of the form scheme:path.
+// Maybe rawURL is of the form scheme:path.
// (Scheme must be [a-zA-Z][a-zA-Z0-9+-.]*)
-// If so, return scheme, path; else return "", rawurl.
-func getscheme(rawurl string) (scheme, path string, err error) {
- for i := 0; i < len(rawurl); i++ {
- c := rawurl[i]
+// If so, return scheme, path; else return "", rawURL.
+func getScheme(rawURL string) (scheme, path string, err error) {
+ for i := 0; i < len(rawURL); i++ {
+ c := rawURL[i]
switch {
case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z':
// do nothing
case '0' <= c && c <= '9' || c == '+' || c == '-' || c == '.':
if i == 0 {
- return "", rawurl, nil
+ return "", rawURL, nil
}
case c == ':':
if i == 0 {
return "", "", errors.New("missing protocol scheme")
}
- return rawurl[:i], rawurl[i+1:], nil
+ return rawURL[:i], rawURL[i+1:], nil
default:
// we have encountered an invalid character,
// so there is no valid scheme
- return "", rawurl, nil
+ return "", rawURL, nil
}
}
- return "", rawurl, nil
+ return "", rawURL, nil
}

// split slices s into two substrings separated by the first occurrence of
@@ -466,15 +466,15 @@
return s[:i], s[i:]
}

-// Parse parses rawurl into a URL structure.
+// Parse parses a raw url into a URL structure.
//
-// The rawurl may be relative (a path, without a host) or absolute
+// The url may be relative (a path, without a host) or absolute
// (starting with a scheme). Trying to parse a hostname and path
// without a scheme is invalid but may not necessarily return an
// error, due to parsing ambiguities.
-func Parse(rawurl string) (*URL, error) {
+func Parse(rawURL string) (*URL, error) {
// Cut off #frag
- u, frag := split(rawurl, '#', true)
+ u, frag := split(rawURL, '#', true)
url, err := parse(u, false)
if err != nil {
return nil, &Error{"parse", u, err}
@@ -483,20 +483,20 @@
return url, nil
}
if err = url.setFragment(frag); err != nil {
- return nil, &Error{"parse", rawurl, err}
+ return nil, &Error{"parse", rawURL, err}
}
return url, nil
}

-// ParseRequestURI parses rawurl into a URL structure. It assumes that
-// rawurl was received in an HTTP request, so the rawurl is interpreted
+// ParseRequestURI parses a raw url into a URL structure. It assumes that
+// url was received in an HTTP request, so the url is interpreted
// only as an absolute URI or an absolute path.
-// The string rawurl is assumed not to have a #fragment suffix.
+// The string url is assumed not to have a #fragment suffix.
// (Web browsers strip #fragment before sending the URL to a web server.)
-func ParseRequestURI(rawurl string) (*URL, error) {
- url, err := parse(rawurl, true)
+func ParseRequestURI(rawURL string) (*URL, error) {
+ url, err := parse(rawURL, true)
if err != nil {
- return nil, &Error{"parse", rawurl, err}
+ return nil, &Error{"parse", rawURL, err}
}
return url, nil
}
@@ -505,27 +505,27 @@
// viaRequest is true, the URL is assumed to have arrived via an HTTP request,
// in which case only absolute URLs or path-absolute relative URLs are allowed.
// If viaRequest is false, all forms of relative URLs are allowed.
-func parse(rawurl string, viaRequest bool) (*URL, error) {
+func parse(rawURL string, viaRequest bool) (*URL, error) {
var rest string
var err error

- if stringContainsCTLByte(rawurl) {
+ if stringContainsCTLByte(rawURL) {
return nil, errors.New("net/url: invalid control character in URL")
}

- if rawurl == "" && viaRequest {
+ if rawURL == "" && viaRequest {
return nil, errors.New("empty url")
}
url := new(URL)

- if rawurl == "*" {
+ if rawURL == "*" {
url.Path = "*"
return url, nil
}

// Split off possible leading "http:", "mailto:", etc.
// Cannot contain escaped characters.
- if url.Scheme, rest, err = getscheme(rawurl); err != nil {
+ if url.Scheme, rest, err = getScheme(rawURL); err != nil {
return nil, err
}
url.Scheme = strings.ToLower(url.Scheme)
@@ -1058,11 +1058,11 @@
// may be relative or absolute. Parse returns nil, err on parse
// failure, otherwise its return value is the same as ResolveReference.
func (u *URL) Parse(ref string) (*URL, error) {
- refurl, err := Parse(ref)
+ refURL, err := Parse(ref)
if err != nil {
return nil, err
}
- return u.ResolveReference(refurl), nil
+ return u.ResolveReference(refURL), nil
}

// ResolveReference resolves a URI reference to an absolute URI from
@@ -1151,8 +1151,8 @@
// splitHostPort separates host and port. If the port is not valid, it returns
// the entire input as host, and it doesn't check the validity of the host.
// Unlike net.SplitHostPort, but per RFC 3986, it requires ports to be numeric.
-func splitHostPort(hostport string) (host, port string) {
- host = hostport
+func splitHostPort(hostPort string) (host, port string) {
+ host = hostPort

colon := strings.LastIndexByte(host, ':')
if colon != -1 && validOptionalPort(host[colon:]) {

5 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one.

To view, visit change 305770. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I191b98b846c9de58b1892e695058c727402b5400
Gerrit-Change-Number: 305770
Gerrit-PatchSet: 7
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Baokun Lee <b...@golangcn.org>
Gerrit-Reviewer: Emmanuel Odeke <emma...@orijtech.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Cluas <imy...@gmail.com>
Gerrit-CC: Tn T <Cl...@live.cn>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages