common

package
v0.0.0-...-f7150f6 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDirectory

func CheckDirectory(path string) (bool, error)

CheckDirectory はディレクトリの存在確認をします。

func CheckDirectoryIsNull

func CheckDirectoryIsNull(filePath string) error

CheckDirectoryIsNull は中身が空のディレクトリかチェックします

func CheckExists

func CheckExists(name string) bool

func CheckFile

func CheckFile(path string) (bool, error)

CheckFile はファイルの存在確認をします。

func CopyFile

func CopyFile(srcPath, targetPath string) error

CopyFile はファイルのコピーをします。

func CreateAndOpenFile

func CreateAndOpenFile(filePath string) (*os.File, error)

CreateAndOpenFile ファイルパスから書き込み用ファイルをオープンします。 ディレクトリが存在しない場合は事前にディレクトリを作成します。

func GetBaseDir

func GetBaseDir() string

GetBaseDirは実行パスのベースディレクトリを返します。

func GetCurrentTime

func GetCurrentTime(sec int, dateFormat DateFormat) string

GetCurrentTime は指定したフォーマット形式で何秒前の現在時刻を取得します。

func GetHostname

func GetHostname() (string, error)

GetHostname はホスト名のエイリアスを取得します。

func GetHostnameAlias

func GetHostnameAlias(hostName string) (string, error)

GetHostnameAlias はホスト名の「.」以降の文字列はカットし、大文字は小文字に変換します。

func GetParentAbsPath

func GetParentAbsPath(inPath string, parentLevel int) (string, error)

GetParentPathAbs は実行パスから上位のディレクトリを絶対パスに変換して返します。

func GetParentPath

func GetParentPath(inPath string, parentLevel int) string

GetParentPathAbs は実行パスから上位のディレクトリを絶対パスに変換して返します。

func GetTimeString

func GetTimeString(dateFormat DateFormat, t time.Time) string

gpfDGetTimeString は指定したフォーマット形式で時刻を変換します。

GPF_DATE_FORMAT_DEFAULT         0
GPF_DATE_FORMAT_YYYYMMDD        1
GPF_DATE_FORMAT_HHMISS          2
GPF_DATE_FORMAT_YYYYMMDD_HHMISS 3
GPF_DATE_FORMAT_DIR             4

func HandleError

func HandleError(w io.Writer, inErr error, message string) error

HandleError はエラーがある場合に、メッセージを付加したエラーをログ出力し、 エラーとして返します

func HandleErrorWithAlert

func HandleErrorWithAlert(w io.Writer, inErr error, message string) error

HandleError はエラーがある場合に、メッセージを付加したエラーをログ出力し、 エラーとして返します

func RemoveAndCreateDir

func RemoveAndCreateDir(filePath string) error

RemoveAndCreateDir はディレクトリを再作成します。

func SetLogLevel

func SetLogLevel(level int) error

; Log level. None 0, FATAL 1, CRIT 2, ERR 3, WARN 4, NOTICE 5, INFO 6, DBG 7 LOG_LEVEL = 5

func TrimPathSeparator

func TrimPathSeparator(path string) string

TrimPathSeparator はパス名(/tmp/log/data/)から前後のセパレータを 取り除きます(tmp/log/data)

Types

type DateFormat

type DateFormat int
const (
	DEFAULT DateFormat = iota
	YYYYMMDD
	HHMISS
	YYYYMMDD_HHMISS
	DIR
)

type DiskStatus

type DiskStatus struct {
	All  uint64 `json:"all"`
	Used uint64 `json:"used"`
	Free uint64 `json:"free"`
}

func CheckDiskFree

func CheckDiskFree(dir string) (DiskStatus, error)

CheckDiskFree は指定したディレクトリのディスク使用量[%]を取得します。

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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