This Go module is a collection of various operations.
The idea is to have a centralized module that has all the commons operations you may need when working on a Go project ( CLI tool, Web Application ... )
This includes operations for :
- File IO operations.
- Command Line Runner
- Maven
- Text / String
The technology stack used in the project is :
- Golang 1.22.x
- You can use any IDE of your choice.
You have a choice of checking this repo out and using the Go Workspaces feature.
Or you can pull this module directly into your projects using :
go get github.com/tlmatjuda/toob-commons
When you are inside your Go module and you need to execute a native commands on the respective Windows or Unix based OS.
The bool
is for when you want to capture the command output into a string when set to true
otherwise it will log out to console as normal.
// Defintion
cli.Exec(command string, commandArgs []string, targetPath string, returnOutput bool) string {}
// Example
cli.Exec("mvn", "clean install", "/project/folder/with/pom.xml", false)
The File IO Operations include :
// Defintion
// Exists
// Checks if a given file Exists on the file system
fileio.Exists(path string) (bool, error) {}
// Example
fileio.Exists("/path/of/the/file.txt")
The Text / String Operations include :
// StringBlank
// Strempty checks whether string contains only whitespace or not
text.StringBlank(s string) bool {}
// Example
text.StringBlank("Thabo Matjuda")
// OR
text.StringBlank(" ")
That's all. These are the operations I found important when building a few CLI tools with Go lang.
I will be adding more as we go.