Skip to content

edoardottt/golazy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


🌴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.
edoardottt.com to contact me.