GoLang
xxxxxxxxxx
package main
import (
"fmt"
"net"
"net/url"
)
func main() {
s := "postgres://user:pass@host.com:5432/path?k=v#f"
u, err := url.Parse(s)
if err != nil {
panic(err)
}
fmt.Println(u.Scheme)
fmt.Println(u.User)
fmt.Println(u.User.Username())
p, _ := u.User.Password()
fmt.Println(p)
fmt.Println(u.Host)
host, port, _ := net.SplitHostPort(u.Host)
fmt.Println(host)
fmt.Println(port)
fmt.Println(u.Path)
fmt.Println(u.Fragment)
fmt.Println(u.RawQuery)
m, _ := url.ParseQuery(u.RawQuery)
fmt.Println(m)
fmt.Println(m["k"][0])
}
postgres user:pass user pass host.com:5432 host.com 5432 /path f k=v map[k:[v]] v
Python - Comprobar si un Número es Positivo, Negativo o 0
JavaScript - Comprobar si una cadena comienza y termina con ciertos caracteres
Linux - Cómo instalar anc-api-tools
Linux - Cómo instalar curvedns
C - Contar el número de dígitos en un entero
Linux - Cómo instalar zenmap
C++ - Comprobar si un número es primo o no
Kotlin - Redondear un número a n decimales
Java - Invertir un número
C - Encuentre el número más grande usando la asignación de memoria dinámica
Java - Crear pirámide y patrón
Kotlin - Calcular la potencia de un número
C++ - Convertir Número Binario a Decimal y viceversa
JavaScript - Contar el número de vocales en una cadena
Kotlin - Encontrar factorial de un número
Linux - Cómo instalar zlib1g-dev
Kotlin - Convertir matriz de bytes a hexadecimal
Kotlin - Comprobar si un número es par o impar
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month