utils

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright (c) 2025 Chakib Ben Ziane <contact@blob42.xyz> and [`gosuki` contributors](https://github.com/blob42/gosuki/graphs/contributors). All rights reserved.

SPDX-License-Identifier: AGPL-3.0-or-later

This file is part of GoSuki.

GoSuki is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

GoSuki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with gosuki. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var (
	TMPDIR = ""
)

Functions

func CamelCase added in v1.2.0

func CamelCase(in string) string

func CheckFileExists

func CheckFileExists(file string) (bool, error)

func CleanFiles

func CleanFiles()

TEST:

func CopyFileToDst added in v1.1.0

func CopyFileToDst(src string, dst string) error

func CopyFilesToTmpFolder

func CopyFilesToTmpFolder(srcglob string, dst string) error

Copy files from src glob to dst folder

func CountLines

func CountLines(f *os.File) (int, error)

func DecodeUnicodeEscapes

func DecodeUnicodeEscapes(s string) string

func DirExists

func DirExists(path string) (bool, error)

func ExpandOnly

func ExpandOnly(paths ...string) (string, error)

ExpandOnly expands a path without following symlinks

func ExpandPath

func ExpandPath(paths ...string) (string, error)

ExpandPath expands a path with environment variables and tilde Symlinks are followed by default

func Extends

func Extends[T comparable](list []T, in ...T) []T

Extends a slice of T with element `in`, like a Set

func FileProcessUsers

func FileProcessUsers(path string) (map[int32]*psutil.Process, error)

func GenStringID

func GenStringID(n int) string

Generate a unique random string with the specified length

func GetDataDir

func GetDataDir() (string, error)

func InList

func InList[T comparable](list []T, elm T) bool

Return true if elm in list

func IsSymlink(path string) (bool, error)

Check if given path is a symlink

func Map

func Map[T, U comparable](f func(item T) U, list []T) []U

map takes a list and a function and returns a new list

func MkDir

func MkDir(dir string) error

MkDir checks if a directory is writable by the current user. It returns an error if the directory does not exist and cannot be created, or if it exists but is not writable by the current user. Otherwise it is created.

func MkGosukiDataDir

func MkGosukiDataDir() error

func MustExpandPath

func MustExpandPath(paths ...string) string

func ReplaceInList

func ReplaceInList(src []string, old string, new string) []string

function that iterates through the list of string, for each element it replaces the occurence of old with new, and returns the updated list

func Shorten added in v1.2.0

func Shorten(path string) string

shortens path using ~

func UseVar

func UseVar(any any)

Use to shutoff golang "unused variable comment"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL