butils

package
v1.0.32 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeWorkingDirToBinPath

func ChangeWorkingDirToBinPath(isWinSvc bool) error

func CidrToNetmask

func CidrToNetmask(bits int) (string, error)

func CreateTarGz added in v1.0.7

func CreateTarGz(destFile string, srcDir string) error

func CreateTarGzFromList added in v1.0.8

func CreateTarGzFromList(output string, paths []string, useStopOnErro bool) error

createTarGz creates a tar.gz archive with the given paths

func ExtractTarGz added in v1.0.7

func ExtractTarGz(tarGzPath, destDir string) error

func GiByteToGByte

func GiByteToGByte(gibibyte int) int

Gibibytes to Gigabytes

  • Gigabytes = Gibibytes x (1024x1024x1024) ÷ (1000x1000x1000)
  • Gigabytes = Gibibytes x 1.073741824

func GiByteToGByteStr

func GiByteToGByteStr(gibibyte int) string

func HexToInt64WithDefault added in v1.0.30

func HexToInt64WithDefault(in string, dft int64) int64

in: 입력값 (ex 0xA1b2, 0Xa1B2) 반환값: int64

  • 빈문자열(") 일 경우 dft 반환됨.
  • 변환 실패 또는 int64 최대 값을 초과한 경우 dft 반환됨

func IsLinux added in v1.0.13

func IsLinux() bool

func KiByteToKByte

func KiByteToKByte(kibibytes int) int

Kibibytes to Kilobytes

  • Kilobytes = Kibibytes x 1024 ÷ 1000
  • Kilobytes = Kibibytes x 1.024

func KiByteToKByteStr

func KiByteToKByteStr(kibibytes int) string

func LogoPrint

func LogoPrint(pName string)

func MiByteToMByte

func MiByteToMByte(mebibyte int) int

Mebibytes to Megabytes

  • Megabytes = Mebibytes x (1024x1024) ÷ (1000x1000)
  • Megabytes = Mebibytes x 1.048576

func MiByteToMByteStr

func MiByteToMByteStr(mebibyte int) string

func ParseVersion added in v1.0.23

func ParseVersion(ver string) (major int, minor int, patch int)

func PrintHex

func PrintHex(in []byte, slice int)

func RandomHex added in v1.0.6

func RandomHex(n int) string

func RemoveNewlines added in v1.0.11

func RemoveNewlines(s string) string

func Rfc3339StrToTime added in v1.0.31

func Rfc3339StrToTime(in string) time.Time

RFC3339 문자열 형식의 시간을 time 으로 변환 입력 :

  • in : "2026-02-19T01:23:45Z"

출력 :

  • 실패 : time.Time 반환 (zero time)
  • 성공 : time.Time 반환

func SafeStringFromMap added in v1.0.9

func SafeStringFromMap(src map[string]interface{}, key string, dftValue string) string

func SetDefaultTimeZone

func SetDefaultTimeZone(name string)

name: "loc", "UTC", "America/New_York", "Asia/Seoul"

func ShortBytes

func ShortBytes(val uint64) string

func ShortBytesIEC

func ShortBytesIEC(val uint64) string

func ShortDuration

func ShortDuration(d time.Duration) string

func TimeToKST added in v1.0.31

func TimeToKST(in time.Time) time.Time

time 을 KST 로 변환 출력 :

  • 실패 : time.Time 반환 (zero time)
  • 성공 : time.Time 반환

func ToBool

func ToBool(in interface{}) (out bool)

func ToFloat64

func ToFloat64(in interface{}) (out float64)

func ToInt

func ToInt(in interface{}) (out int)

func ToInt64

func ToInt64(in interface{}) (out int64)

func ToMaskString added in v1.0.25

func ToMaskString(in interface{}) (out string)

func ToString

func ToString(in interface{}) (out string)

func ToUint

func ToUint(in interface{}) (out uint)

func ToUint64

func ToUint64(in interface{}) (out uint64)

func TruncateWithEllipsis added in v1.0.32

func TruncateWithEllipsis(s string, limit int) string

func UnitByteToByte

func UnitByteToByte(val uint64, unit string) uint64

함수 내에서 unit 을 ToLower + TrimSpace 처리함 unit : kb, mb, gb, tb

Types

type ResLinuxKernelVersion added in v1.0.13

type ResLinuxKernelVersion struct {
	VersionString string
	Version       struct {
		Major int
		Minor int
		Patch int
		Extra string
	}
}

func GetLinuxKernelVersion added in v1.0.13

func GetLinuxKernelVersion() (ResLinuxKernelVersion, error)

type ResLinuxOsRelease added in v1.0.15

type ResLinuxOsRelease struct {
	Name string

	VersionString string
	Version       struct {
		Major int
		Minor int
		Patch int
		Extra string
	}
}

func GetLinuxOsRelease added in v1.0.13

func GetLinuxOsRelease() (ResLinuxOsRelease, error)

type ResNetworkInterface added in v1.0.21

type ResNetworkInterface struct {
	Type      string                       `json:"type"`                // 인터페이스 타입 (Physical, Virtual 등)
	Name      string                       `json:"name"`                // 인터페이스 이름
	Mac       string                       `json:"mac"`                 // MAC 주소
	Addresses []ResNetworkInterfaceAddress `json:"addresses,omitempty"` // Addresses
}

func GetNetworkInterfaces added in v1.0.21

func GetNetworkInterfaces() (ret []ResNetworkInterface, err error)

GetPhysicalInterfaces : 물리 네트워크 인터페이스 목록 조회 함수

type ResNetworkInterfaceAddress added in v1.0.21

type ResNetworkInterfaceAddress struct {
	Cidr    string `json:"cidr"`    // Classless Inter-Domain Routing
	Ip      string `json:"ip"`      // IPv4 주소
	Netmask string `json:"netmask"` // 넷마스크
}

type ResPhysicalInterface added in v1.0.18

type ResPhysicalInterface struct {
	Name    string `json:"name"`    // 인터페이스 이름
	Type    string `json:"type"`    // 인터페이스 타입 (Physical, Virtual 등)
	Mac     string `json:"mac"`     // MAC 주소
	Cidr    string `json:"cidr"`    // Classless Inter-Domain Routing
	Ip      string `json:"ip"`      // IPv4 주소
	Netmask string `json:"netmask"` // 넷마스크
}

func GetPhysicalInterfaces added in v1.0.18

func GetPhysicalInterfaces() ([]ResPhysicalInterface, error)

GetPhysicalInterfaces : 물리 네트워크 인터페이스 목록 조회 함수

Jump to

Keyboard shortcuts

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