URIjava
:golang
Uniform Resource Identifierweb
,統一資源標識符;app
URLide
:spa
Uniform Resource Locatorcode
,統一資源定位符;orm
URNci
:資源
Uniform Resource Name
,統一資源名稱。
其中,
URL,URN
是
URI
的子集。
URI
:
Uniform Resource Identifier
,統一資源標識符;
URL
:
Uniform Resource Locator
,統一資源定位符;
URN
:
Uniform Resource Name
,統一資源名稱。
其中,
URL,URN
是
URI
的子集。
URI
:
Uniform Resource Identifier
,統一資源標識符;
URL
:
Uniform Resource Locator
,統一資源定位符;
URN
:
Uniform Resource Name
,統一資源名稱。
其中,
URL,URN
是
URI
的子集。
URI
:
Uniform Resource Identifier
,統一資源標識符;
URL
:
Uniform Resource Locator
,統一資源定位符;
URN
:
Uniform Resource Name
,統一資源名稱。
其中,
URL,URN
是
URI
的子集。
1. 概念和關係
URI:Uniform Resource Identifier,即統一資源標誌符,用來惟一的標識一個資源。
URL:Uniform Resource Locator,統一資源定位符。即URL能夠用來標識一個資源。
URN:Uniform Resource Name,統一資源命名。即經過名字來表示資源的。
集中URL,URN是URI的一種實現方式。互聯網最普遍使用的是URL
URI格式:[scheme:] scheme-specific-part
mailto:jeff@javajeff.com
news:comp.go.lang
URI能夠進一步分爲不透明的(opaque)和分層(hierarchical)的兩類
opaque指的是URI的scheme-specific-part部分不以/開頭,是一個整個部分,沒有分層結構。如:mailto:jeff@javajeff.com , news:comp.go.lang
hierarchical指的是以/開頭,scheme-specific-part能夠由好幾部分組成
2. golang 對URI,URL實現
以斜槓開頭解析爲 :[scheme:][//[userinfo@]host][/]path[?query][#fragment] 不然解析爲(opaque):scheme:opaque[?query][#fragment] type URL struct { Scheme string Opaque string // encoded opaque data User *Userinfo // username and password information Host string // host or host:port Path string // path (relative paths may omit leading slash) RawPath string // encoded path hint (see EscapedPath method) ForceQuery bool // append a query ('?') even if RawQuery is empty RawQuery string // encoded query values, without '?' Fragment string // fragment for references, without '#' }