Go to file
Stefan Goppelt a24fffa0e6 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
docs 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
scripts Add AGENTS and Definition of Done documentation; implement project standards reconciliation scripts 2026-03-29 13:07:14 +02:00
.drone.yml Updated modules and build 2023-03-08 09:57:02 +01:00
.gitignore 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
AGENTS.md 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
README.md 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
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 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_windows_test.go 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
utils.go New method 2022-03-17 11:15:17 +01:00
utils_test.go 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

README.md

Go utility library

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