Skip to content

x-ethr/text

Repository files navigation

text - String Utilities Package

The purpose of text is to provide string utilities, but with special considerations relating to web-service(s), cloud providers, and external APIs.

Interfacing with packages such as AWS and Stripe GO SDKs often require working with pointer inputs and outputs. Such cases can result in undesired, unexpected behavior. When writing API services, tracing issues can become difficult.

That's where the text package's variadic options are perhaps the most notable; configurations can be set that will log unexpected nil or zeroth input arguments.

Documentation

Official godoc documentation (with examples) can be found at the Package Registry.

Usage

Add Package Dependency
go get -u github.com/x-ethr/text
Import & Implement

main.go

package main

import (
    "github.com/x-ethr/text"
)

func main() {
    const example = "v-value"

    ptr := text.Pointer(example) // initialize ptr as a reference to example

    // --> optionally construct text.Options for logging
    ptr = text.Pointer(example, text.Variadic(o text.Options) {
        o.Log = true // output a warning if string is empty
    })

    ...
}

Contributions

See the Contributing Guide for additional details on getting started.