go url parse
url = schema(http/https) + "//" + host(ip:port/domain:port) + path(/xxx) + "?" + rawQuery(xxx=xxx)
package main
import (
"fmt"
"net/url"
)
func parseUrlInfo(urlStr string) {
u, err := url.Parse(urlStr)
if err != nil {
fmt.Printf("parse url %s failed: %v\n", urlStr, err)
return
}
fmt.Printf("schema:%s host:%s path:%s rawQuery:%s\n", u.Scheme, u.Host, u.Path, u.RawQuery)
}
func main() {
parseUrlInfo("http://127.0.0.1:1000/index.html?a=b")
parseUrlInfo("https://www.baidu.com/index.html?a=b")
}

但是,在k8s restclient.Config中,没有schema,Host是https://xxx:xxx,APIPath是/xxx。

浙公网安备 33010602011771号