Skip to content
Node: new URL(str)github.com/sahilkhaire/gox/url

URL.Parse

Overview

Parse parses a URL string (url.parse).

If you are coming from Node.js, the closest pattern is new URL(str).

Method on URL — call it on a value of that type after constructing or receiving one from a constructor.

Signature

go
func Parse(raw string) (*URL, error)

Compare: Node.js · Standard Go · gox

js
new URL('https://example.com/path');
go
u, err := url.Parse(rawURL)
go
import "github.com/sahilkhaire/gox/url"

u, err := url.Parse("https://example.com/path")

Example

go
import "github.com/sahilkhaire/gox/url"

u, err := url.Parse("https://example.com/path")

Tips

Obtain a URL value first (see constructors on the package overview), then call Parse.

Standard library alternative

Use the standard library directly:

go
u, err := url.Parse(rawURL)

Back to url package overview

MIT Licensed · Built for Node.js developers moving to Go