import "net/url" // URL with query string u, _ := url.Parse("https://example.com/search?q=golang&limit=10&sort=desc") // Get the query values q := u.Query() // q => map[q:[golang] limit:[10] sort:[desc]] // Delete the 'sort' value q.Del("sort") // q => map[q:[golang] limit:[10]] // Update the URL's query string with the modified values u.RawQuery = q.Encode() // https://example.com/search?q=golang&limit=10
import "net/url" // URL with query string u, _ := url.Parse("https://example.com/path?param1=value1¶m2=value2") // Get the query values q := u.Query() // q => map[param1:[value1] param2:[value2]] // Delete both params q.Del("param1") q.Del("param2") // Update the URL's query string with the modified values u.RawQuery = q.Encode() // https://example.com/pathIn both examples, the Del method is used to remove a specific key-value pair from the query string of a given URL. The modified values are then re-encoded into the query string and the URL is updated accordingly. This method is part of the standard net/url package in Go.