slitu

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 16 Imported by: 5

README

slitu

Go Reference Go Report Card

Avoid meaningless package names like util, common, misc, api, types, and interfaces.

- Go Wiki

So, i have to avoid package name utils.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAssert = errors.New("syscall.Stat_t assertion failed")
)

Functions

func CountFileLines added in v1.0.6

func CountFileLines(path string) (int, error)

CountFileLines returns the number lines in file.

func GetFileGroup added in v1.0.3

func GetFileGroup(file string) (*user.Group, error)

GetFileGroup returns the user.Group struct of file. Returns ErrAssert if syscall assertion failed or UnknownGroupIdError if failed to get owner from the GID.

func GetFileOwner added in v1.0.3

func GetFileOwner(file string) (*user.User, error)

GetFileOwner returns the owner user.User struct of file. Returns ErrAssert if syscall assertion failed or UnknownUserIdError if failed to get owner from the UID.

func IsDigit added in v1.0.5

func IsDigit(c byte) bool

IsDigit returns whether c is a number (0-9).

func IsDir added in v1.0.7

func IsDir(path string) bool

IsDir returns whether path is a directory..

It will panic is error is other than fs.ErrNotExist!

func IsExists added in v1.0.7

func IsExists(path string) bool

IsExists returns whether path is exists.

It will panic is error is other than "no such file or directory"!

func IsExistsAndDir added in v1.0.7

func IsExistsAndDir(path string) bool

IsExistsAndDir returns whether path is exists and a directory.

It will panic is error is other than fs.ErrNotExist!

func IsHexa added in v1.0.5

func IsHexa(c byte) bool

IsHexa returns whether c is a hexadecimal (0-9 a-f A-F).

func IsLineInFile added in v1.0.1

func IsLineInFile(path, s string) (bool, error)

IsLineInFile check whether s is exactly a line in file in path. A line in the file does not contains the newline character ("\n"). This function uses bufio.Scanner to able to handle large files.

func IsLowerLetter added in v1.0.5

func IsLowerLetter(c byte) bool

IsLowerLetter returns whether c is a lower case letter (a-z).

func IsUpperLetter added in v1.0.5

func IsUpperLetter(c byte) bool

IsUpperLetter returns whether c is an upper case letter (A-Z).

func RandomString added in v1.0.4

func RandomString(chars []byte, l int) string

RandomString generates a random string from chars with length l. If chars nil/empty or l < 1, returns an empty string ("").

func SHA256Str added in v1.0.2

func SHA256Str(v string) string

SHA256Str calculates the SHA256 checksum of v and returns the hex encoded string result.

func Sleep

func Sleep(ctx context.Context, d time.Duration)

Sleep is a context aware sleep function, which is sleep for d duration or return if ctx is cancelled.

Types

This section is empty.

Jump to

Keyboard shortcuts

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