Go Package net/url: Difference between revisions
Jump to navigation
Jump to search
Line 31: | Line 31: | ||
fmt.Printf("RawPath: %s\n", l.RawPath) | fmt.Printf("RawPath: %s\n", l.RawPath) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=<tt>url.QueryEscape()</tt>= |
Revision as of 20:48, 25 July 2024
External
Internal
Overview
URL Parsing
import (
"fmt"
"net/url"
)
s := "https://localhost.apple.com:8099/some/path/?color=blue#something"
l, err := url.Parse(s)
if err != nil {
panic(err)
}
fmt.Printf("Scheme: %s\n", l.Scheme) // "https"
fmt.Printf("Host: %s\n", l.Host) // "localhost.apple.com:8099"
fmt.Printf("Path: %s\n", l.Path) // "/some/path/"
fmt.Printf("RawQuery: %s\n", l.RawQuery) // "color=blue"
fmt.Printf("Fragment: %s\n", l.Fragment) // "something"
fmt.Printf("User: %s\n", l.User)
fmt.Printf("OmitHost: %t\n", l.OmitHost) // false
fmt.Printf("ForceQuery: %t\n", l.ForceQuery) // false
fmt.Printf("Opaque: %s\n", l.Opaque)
fmt.Printf("RawFragment: %s\n", l.RawFragment)
fmt.Printf("RawPath: %s\n", l.RawPath)