net

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package net provides simple networking helper functions

Index

Constants

View Source
const (
	// TCP is a protocol string constant
	TCP = "tcp"

	// UDP is a protocol string constant
	UDP = "udp"
)

Variables

This section is empty.

Functions

func DirURL

func DirURL(uri string) (result string)

DirURL behaves much like the path.Dir only it doesn't garble the schema

func DisableProxy

func DisableProxy(proxy *url.URL)

DisableProxy unsets the http_proxy env var and sets the http.DefaultTransport to not use a proxy

func DownloadFile

func DownloadFile(url, dst string, perms ...uint32) (result string, err error)

DownloadFile from the given URL to the given destination returning the full path to the resulting downloaded file

func EnableProxy

func EnableProxy(proxy *url.URL)

EnableProxy sets the http_proxy env var and sets the http.DefaultTransport to use a proxy

func JoinURL

func JoinURL(elems ...string) (result string)

JoinURL will join and append the given paths to the first element which is assumed will be the schema of the URL. Will also normalize the schema.

func NormalizeURL

func NormalizeURL(uri string) (result string)

NormalizeURL parses the URL and corrects case and other oddities. 1. properly formats the schema

func Ping

func Ping(proto, addr string, timeout ...int) (err error)

Ping simply checks if the given protocol, address is accessible and listening. An error will be returned if the ping was not successful. optional timeout in seconds defaults to 1

func SplitURL

func SplitURL(uri string) (pieces []string)

SplitURL will split the URL into pieces much as strings.Split(url, "/") would except it keeps the schema intact if it exists.

Types

This section is empty.

Directories

Path Synopsis
Package agent provides simple agent helper functions
Package agent provides simple agent helper functions
Package mech provides some simple automation for working with web sites
Package mech provides some simple automation for working with web sites

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL