stefan 170c8ea981
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
fix(ci): add missing base_url to gitea-release plugin
2026-03-29 17:24:55 +02:00
2022-03-17 11:11:17 +01:00
2022-03-17 11:11:17 +01:00
2026-03-29 17:09:13 +02:00

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 © 2026 yoorie.de

S
Description
No description provided
Readme
145 KiB
v0.6.0
Latest
2026-03-29 15:25:37 +00:00
Languages
Shell 61.9%
Go 38.1%