GO語言"net/url"包中"URL.EscapedPath"類型的用法及代碼示例。
用法:
func(u *URL) EscapedPath() string
EscapedPath 返回 u.Path 的轉義形式。一般來說,任何路徑都有多種可能的轉義形式。 EscapedPath 在 u.Path 的有效轉義時返回 u RawPath。否則 EscapedPath 忽略 u RawPath 並自行計算轉義形式。 String 和RequestURI 方法使用EscapedPath 來構造它們的結果。一般來說,代碼應該調用EscapedPath,而不是直接讀取你的RawPath。
例子:
package main
import (
"fmt"
"log"
"net/url"
)
func main() {
u, err := url.Parse("http://example.com/x/y%2Fz")
if err != nil {
log.Fatal(err)
}
fmt.Println("Path:", u.Path)
fmt.Println("RawPath:", u.RawPath)
fmt.Println("EscapedPath:", u.EscapedPath())
}
輸出:
Path: /x/y/z RawPath: /x/y%2Fz EscapedPath: /x/y%2Fz
相關用法
- GO URL.EscapedFragment用法及代碼示例
- GO URL.Hostname用法及代碼示例
- GO URL.Port用法及代碼示例
- GO URL.ResolveReference用法及代碼示例
- GO URL.Query用法及代碼示例
- GO URL.Redacted用法及代碼示例
- GO URL.Parse用法及代碼示例
- GO URL.String用法及代碼示例
- GO URL.UnmarshalBinary用法及代碼示例
- GO URL.MarshalBinary用法及代碼示例
- GO URL.RequestURI用法及代碼示例
- GO URL.IsAbs用法及代碼示例
- GO URL用法及代碼示例
- GO UDPConn.WriteTo用法及代碼示例
- GO Unmarshal用法及代碼示例
- GO UnaryOp用法及代碼示例
- GO Unsetenv用法及代碼示例
- GO Unquote用法及代碼示例
- GO Unwrap用法及代碼示例
- GO UnquoteChar用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 URL.EscapedPath。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。