utils

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

README

utils

some go-utils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertExcelToCSV

func ConvertExcelToCSV(filePath string) error

ConvertExcelToCSV converts the Excel file to the CSV format file.

func ConvertExcelToTSV

func ConvertExcelToTSV(filePath string) error

ConvertExcelToTSV converts the Excel file to the TSV format file.

func ConvertStringToCharByte added in v0.0.2

func ConvertStringToCharByte(s string) []byte

ConvertStringToCharByte converts the given string(char) to a byte slice.

func ConvertStringToCharRune added in v0.0.2

func ConvertStringToCharRune(s string) rune

ConvertStringToCharRune converts the given string(char) to a rune.

func CopyByReader

func CopyByReader(src io.Reader, dst io.Writer, buffer ...[]byte) error

CopyByReader copies the src Reader to the dst Writer.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies the src file to the dst file.

func HasNullByteInFile added in v0.0.2

func HasNullByteInFile(filePath string) (bool, error)

HasNullByteInFile checks the file has the ASCII 0 or not.

func HasNullByteInReader added in v0.0.2

func HasNullByteInReader(r io.Reader) (bool, error)

HasNullByteInReader checks the reader has the ASCII 0 or not.

func IsCIDR added in v0.0.2

func IsCIDR(i string) bool

IsCIDR checks if i is a valid CIDR.

func IsDarwin added in v0.0.2

func IsDarwin() bool

IsDarwin checks if host is darwin.

func IsDomain added in v0.0.2

func IsDomain(i any) bool

IsDomain checks if i is a domain.

func IsIP added in v0.0.2

func IsIP(i string) bool

IsIP checks if i is an IP address.

func IsIPv4 added in v0.0.2

func IsIPv4(i string) bool

IsIPv4 checks if i is an ipv4 address.

func IsIPv4CIDR added in v0.0.2

func IsIPv4CIDR(i string) bool

IsIPv4CIDR checks if i is a valid IPv4 CIDR.

func IsIPv6 added in v0.0.2

func IsIPv6(i string) bool

IsIPv6 checks if i is an ipv6 address.

func IsIPv6CIDR added in v0.0.2

func IsIPv6CIDR(i string) bool

IsIPv6CIDR checks if i is a valid IPv6 CIDR.

func IsPathExist added in v0.0.2

func IsPathExist(f string) bool

IsPathExist checks if f is a valid path.

func IsURL added in v0.0.2

func IsURL(u string) bool

IsURL checks if u is a valid url.

func IsWindows added in v0.0.2

func IsWindows() bool

IsDarwin checks if host is windows.

func ListFiles

func ListFiles(dir, contentType string, fileExteinsion ...string) []string

ListFiles returns a slice containing file paths for a given content type and file extension.

func RemoveNullByte

func RemoveNullByte(data []byte) []byte

RemoveNullByte removes the ASCII 0 in the data.

func RemoveNullByteInFile added in v0.0.2

func RemoveNullByteInFile(filePath string) error

RemoveNullByteInFile removes the ASCII 0 in the file.

func RemoveNullByteInReader added in v0.0.2

func RemoveNullByteInReader(reader io.Reader) (io.Reader, error)

RemoveNullByteInReader removes the ASCII 0 in reader.

func ReplaceDelimiter

func ReplaceDelimiter(filePath string, old, new string) error

ReplaceDelimiter replaces the old delimiter with the new delimiter in the filePath.

func ReplaceDosToUnix

func ReplaceDosToUnix(filePath string) error

ReplaceDosToUnix replaces the Windows end of line(eol) with the Unix eol in the filePath.

func SkipFirstRow

func SkipFirstRow(f *os.File) error

SkipFirstRow skips the first row in f.

func ToInt64 added in v0.0.2

func ToInt64(v any) (int64, error)

ToInt64 converts v to int64 value, if input is not numerical, return 0 and error.

func UnZip

func UnZip(zip, dst string) error

UnZip unzips the file and save it to dst directory.

func Version added in v0.0.2

func Version() string

Version returns version information string containing git tag, git commit hash, build time, runtime and pkg path.

func Zip

func Zip(src, zip string) error

Zip creates a zip file, src could be a single file or a directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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