🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

github.com/BufferZoneCorp/go-stdlib-ext

Package Overview
Dependencies
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/BufferZoneCorp/go-stdlib-ext

Source
Go Modules
Version
v0.4.0
Version published
Created
Source

go-stdlib-ext

Go Version License

go-stdlib-ext provides two focused packages that fill gaps in the Go standard library:

  • strutil — ergonomic string manipulation helpers (truncation, slugification, case conversion, padding, and more)
  • sysutil — system-level utilities for environment variables, temporary directories, and platform introspection

Both packages have zero external dependencies and are safe for use in library code.

Installation

go get github.com/BufferZoneCorp/go-stdlib-ext

Import paths

import "github.com/BufferZoneCorp/go-stdlib-ext/strutil"
import "github.com/BufferZoneCorp/go-stdlib-ext/sysutil"

Usage

strutil

package main

import (
    "fmt"

    "github.com/BufferZoneCorp/go-stdlib-ext/strutil"
)

func main() {
    // Truncate long strings with a custom suffix
    title := strutil.Truncate("A very long article title that should be shortened", 30, "...")
    fmt.Println(title) // A very long article title th...

    // Convert to URL-safe slug
    slug := strutil.Slugify("Hello, World! This is a Test.")
    fmt.Println(slug) // hello-world-this-is-a-test

    // Case conversions
    fmt.Println(strutil.SnakeCase("MyStructField"))  // my_struct_field
    fmt.Println(strutil.CamelCase("my_struct_field")) // myStructField

    // Pad a string to a fixed width
    padded := strutil.Pad("42", 6, '0', true)
    fmt.Println(padded) // 000042

    // Word count and reversal
    fmt.Println(strutil.CountWords("the quick brown fox")) // 4
    fmt.Println(strutil.Reverse("golang"))                 // gnalog
}

sysutil

package main

import (
    "fmt"
    "log"

    "github.com/BufferZoneCorp/go-stdlib-ext/sysutil"
)

func main() {
    // Read an env var with a fallback default
    dsn := sysutil.EnvOrDefault("DATABASE_URL", "postgres://localhost/mydb")
    fmt.Println(dsn)

    // Inspect current platform
    info := sysutil.PlatformInfo()
    fmt.Printf("running on %s/%s (host: %s)\n", info["os"], info["arch"], info["hostname"])

    // Create a scoped temporary directory
    dir, err := sysutil.TempDir("myapp-")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("temp dir:", dir)
}

API reference

strutil

FunctionSignatureDescription
Truncate(s string, maxLen int, suffix string) stringShorten a string to maxLen runes, appending suffix if truncated
Slugify(s string) stringConvert a string to a URL-safe slug
CamelCase(s string) stringConvert snake_case or kebab-case to camelCase
SnakeCase(s string) stringConvert CamelCase to snake_case
Pad(s string, length int, padChar rune, left bool) stringPad a string to the given length
CountWords(s string) intCount whitespace-delimited words
Reverse(s string) stringReverse the runes of a string

sysutil

FunctionSignatureDescription
EnvOrDefault(key, defaultVal string) stringReturn the env var value or defaultVal
PlatformInfo() map[string]stringReturn OS, architecture, and hostname
TempDir(prefix string) (string, error)Create a temporary directory

Requirements

  • Go 1.21 or later
  • No external dependencies

License

MIT — see LICENSE.

FAQs

Package last updated on 23 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts