golazy

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: GPL-3.0 Imports: 8 Imported by: 30

README ΒΆ


🌴golazy🍸

Golang module exporting general purpose functions I get tired of rewriting every time

workflows Go Reference


go get github.com/edoardottt/golazy

Name Description
ScanInputStdin() []string It returns the array of elements taken as input on stdin.
RemoveDuplicateStrings(strSlice []string) []string It removes duplicates from a slice of strings taken as input and returns the result
RemoveDuplicateInts(intSlice []int) []int It removes duplicates from a slice of integers taken as input and returns the result
RemoveDuplicateFloats(floatSlice []float64) []float64 It removes duplicates from a slice of floats taken as input and returns the result
AppendOutputToTxt(output string, filename string) It tries to append the output string in the file "filename" taken as input.
AppendOutputToTxtAndExit(output string, filename string) It appends the output string in the file "filename" taken as input, but if it encounters an error it logs it and exits.
GetHost(input string) (string, error) It takes as input a string and tries to parse it as url, if it's a well formatted url it returns the host (the domain if you prefer)
GetProtocol(input string) (string, error) It takes as input a string and tries to parse it as url, if it's a well formatted url it returns the protocol
HasProtocol(input string) bool It takes as input a string and checks if it has a protocol ( like in a URI/URL)
RemoveProtocol(input string) string It removes the protocol from the input string (something://...). If it's not present it returns the input
RemovePort(input string) string It removes port from the input string. If it's not present it returns the input
SameDomain(url1 string, url2 string) bool It checks if two urls have the same domain
GetPath(input string) (string, error) It returns the path of the input string (if correctly URL-formatted)
ReadFileLineByLine(inputFile string) []string It reads from a file taken as input and returns a slice of strings (duplicates allowed).
GenerateRandomUserAgent() string It generates a Random User Agent.

License πŸ“

This repository is under GNU General Public License v3.0.
edoardoottavianelli.it to contact me.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	Permission0644 = 0644
)

Variables ΒΆ

This section is empty.

Functions ΒΆ

func AppendOutputToTxt ΒΆ

func AppendOutputToTxt(output string, filename string)

AppendOutputToTxt tries to append the output string in the file `filename` taken as input.

func AppendOutputToTxtAndExit ΒΆ

func AppendOutputToTxtAndExit(output string, filename string)

AppendOutputToTxtAndExit appends the output string in the file `filename` taken as input. ---> If it encounters an error, it logs the error and exits !!!!

func GenerateRandomUserAgent ΒΆ

func GenerateRandomUserAgent() string

GenerateRandomUserAgent generates a random user agent (can be Chrome or Firefox).

func GetHost ΒΆ

func GetHost(input string) (string, error)

GetHost takes as input a string and tries to parse it as url, if it's a well formatted url this function returns the host (the domain if you prefer).

func GetPath ΒΆ

func GetPath(input string) (string, error)

GetPath returns the path of the input string (if correctly URL-formatted).

func GetProtocol ΒΆ

func GetProtocol(input string) (string, error)

GetProtocol takes as input a string and tries to parse it as url, if it's a well formatted url this function returns the protocol (the scheme if you prefer).

func HasProtocol ΒΆ

func HasProtocol(input string) bool

HasProtocol takes as input a string and checks if it has a protocol ( like in a URI/URL).

func ReadFileLineByLine ΒΆ

func ReadFileLineByLine(inputFile string) []string

ReadFileLineByLine reads from a file taken as input and returns a slice of strings (duplicates allowed).

func RemoveDuplicateValues ΒΆ

func RemoveDuplicateValues[T comparable](slice []T) []T

RemoveDuplicateValues removes duplicates from a slice of T taken as input and returns the result.

func RemovePort ΒΆ

func RemovePort(input string) string

RemovePort removes port from the input string If it's not present it returns the input.

func RemoveProtocol ΒΆ

func RemoveProtocol(input string) string

RemoveProtocol removes the protocol from the input string (something://...) If it's not present it returns the input.

func SameDomain ΒΆ

func SameDomain(url1 string, url2 string) bool

SameDomain checks if two urls have the same domain.

func ScanInputStdin ΒΆ

func ScanInputStdin() []string

ScanInputStdin return the array of elements taken as input on stdin.

func Version ΒΆ

func Version() string

Version returns the version as string.

Types ΒΆ

This section is empty.

Jump to

Keyboard shortcuts

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