Go to file
Stefan Goppelt 6236717fdb Refactor documentation for clarity and consistency, update test function naming convention 2026-03-29 15:01:08 +02:00
.githooks Add configuration files and scripts for project standards enforcement 2026-03-29 13:48:46 +02:00
docs Refactor documentation for clarity and consistency, update test function naming convention 2026-03-29 15:01:08 +02:00
scripts - apply latest AGENTS and DoD templates 2026-03-29 14:15:29 +02:00
.drone.yml Update CI pipeline to use Go 1.25.8, enhance Definition of Done with SonarQube checks, refactor SID allocation in Windows functions, and improve test coverage for JoiningSlash function. 2026-03-29 14:54:31 +02:00
.editorconfig - apply latest AGENTS and DoD templates 2026-03-29 14:15:29 +02:00
.gitattributes - apply latest AGENTS and DoD templates 2026-03-29 14:15:29 +02:00
.gitignore - apply latest AGENTS and DoD templates 2026-03-29 14:15:29 +02:00
AGENTS.md Refactor documentation for clarity and consistency, update test function naming convention 2026-03-29 15:01:08 +02:00
README.md Refactor documentation for clarity and consistency, update test function naming convention 2026-03-29 15:01:08 +02:00
coverage Add .gitignore, enhance AGENTS and Definition of Done documentation, update README with project details, and improve test coverage for Windows-specific functionality 2026-03-29 13:31:23 +02:00
go.mod Add .gitignore, enhance AGENTS and Definition of Done documentation, update README with project details, and improve test coverage for Windows-specific functionality 2026-03-29 13:31:23 +02:00
go.sum Add .gitignore, enhance AGENTS and Definition of Done documentation, update README with project details, and improve test coverage for Windows-specific functionality 2026-03-29 13:31:23 +02:00
os_darwin.go Add os specific stuff 2022-03-17 11:11:17 +01:00
os_linux.go Add os specific stuff 2022-03-17 11:11:17 +01:00
os_windows.go Fix formatting of variable declarations in os_windows.go 2026-03-29 14:54:46 +02:00
os_windows_test.go Refactor documentation for clarity and consistency, update test function naming convention 2026-03-29 15:01:08 +02:00
utils.go Update CI pipeline to use Go 1.25.8, enhance Definition of Done with SonarQube checks, refactor SID allocation in Windows functions, and improve test coverage for JoiningSlash function. 2026-03-29 14:54:31 +02:00
utils_test.go Update CI pipeline to use Go 1.25.8, enhance Definition of Done with SonarQube checks, refactor SID allocation in Windows functions, and improve test coverage for JoiningSlash function. 2026-03-29 14:54:31 +02:00

README.md

Go utility library

yoorie.de logo

Build Status

Project Description

This repository provides a small, cross-platform utility package for Go projects. It focuses on common helpers that are often reimplemented in multiple services, such as file checks, safe path joining for URL-like strings, and OS-specific configuration directory handling.

The package is intentionally lightweight and easy to reuse in CLI tools, daemons, and backend services.

Included Utilities

  • FileExists(fileName string) bool
    • Returns whether a file exists on disk.
  • JoiningSlash(elem ...string) string
    • Joins path segments with exactly one slash between elements.
  • GetGlobalConfigurationDirectory(appname string) string
    • Returns an operating-system-specific global configuration directory.
    • Linux and macOS: /etc/<appname>
    • Windows: %APPDATA%\\<appname>
  • GetGlobalConfigurationFile(appname string, file string) string
    • Builds a full path to a config file inside the global config directory.
  • IsSuperUser() bool
    • Detects whether the current process runs with elevated privileges.

Installation

go get scm.yoorie.de/go-lib/util

Example

package main

import (
 "fmt"

 "scm.yoorie.de/go-lib/util"
)

func main() {
 if util.FileExists("config.yaml") {
  fmt.Println("config file found")
 }

 fmt.Println(util.JoiningSlash("/api", "v1", "users"))
 fmt.Println(util.GetGlobalConfigurationFile("myapp", "config.yaml"))
}

Copyright © 2023 yoorie.de