baseURL, _ := url.Parse("https://example.com") refURL, _ := url.Parse("/path/to/something") resolvedURL := baseURL.ResolveReference(refURL) fmt.Println(resolvedURL.String())
baseURL, _ := url.Parse("https://example.com/path/") refURL, _ := url.Parse("../to/something") resolvedURL := baseURL.ResolveReference(refURL) fmt.Println(resolvedURL.String())This code takes a base URL and a relative reference URL and uses the ResolveReference function to create a new URL that is the combination of the two. The resulting URL, "https://example.com/to/something", is then printed to the console. Package Library: net/url