π Http β
go
import (
"fmt"
"github.com/thuongtruong109/gouse"
)
1. Http check url β
Description: Check if a URL status
Input params: (url string)
go
func HttpCheckUrl() {
isOk, statusCode, err := gouse.CheckUrl("https://google.com")
if err != nil {
panic(err)
}
println("Response: ", isOk)
println("Status code: ", statusCode)
}
2. Http connect time β
Description: Calculate the time it takes to connect to a URL
Input params: (url string)
go
func HttpConnectTime() {
connectTime, err := gouse.ConTimeUrl("https://google.com")
if err != nil {
panic(err)
}
fmt.Printf("Connect time: %fs\n", connectTime)
}
3. Http encode url β
Description: Encode a URL
Input params: (url string)
go
func HttpEncodeUrl() {
println("Encode: ", gouse.EncodeUrl("https://google.com"))
}
4. Http decode url β
Description: Decode a URL
Input params: (url string)
go
func HttpDecodeUrl() {
println("Decode: ", gouse.DecodeUrl("https%3A%2F%2Fgoogle.com"))
}
5. Http header url β
Description: Get the header of a URL
Input params: (url string)
go
func HttpHeaderUrl() {
header, err := gouse.HeaderUrl("https://google.com")
if err != nil {
panic(err)
}
fmt.Println(gouse.Map2Str(header))
}
6. Http port checker β
Description: Check if a port is open
Input params: (protocol, hostname string, port int)
go
func HttpPortChecker() {
open := gouse.CheckPort("tcp", "localhost", 1313)
fmt.Printf("Port Open: %t\n", open)
}
7. Http port scanner β
Description: Scan for open ports on a given host.
Input params: (protocol, hostname string, startPort, endPort int)
go
func HttpPortScanner() {
gouse.ScanPort("tcp", "127.0.0.1", 3000, 8080)
}
8. Http open url β
Description: Open a URL in the default browser
Input params: (url string)
go
func HttpOpenUrl() {
gouse.OpenUrl("https://google.com")
}