library: net/url

This commit is contained in:
赵英杰
2024-08-05 17:26:36 +08:00
parent 4bff9cc3df
commit 3a68dee850
2 changed files with 21 additions and 0 deletions

20
_cmptest/urldemo/url.go Normal file
View File

@@ -0,0 +1,20 @@
package main
import (
"fmt"
"log"
"net/url"
)
func main() {
u, err := url.Parse("http://foo.example.com/foo?bar=1")
if err != nil {
log.Fatal(err)
}
u.Scheme = "https"
u.Host = "bar.example.com"
q := u.Query()
q.Set("bar", "2")
u.RawQuery = q.Encode()
fmt.Println(u)
}