utils

package
v0.0.0-...-205da4a Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Acquire

func Acquire(size BufferSize) *bytes.Buffer

func BufferedRead

func BufferedRead(name string, buf *bytes.Buffer) error

func CGroup

func CGroup(pid int, hostfs ...string) (podId, container string, err error)

func Decrypt

func Decrypt(res string) (string, error)

func DecryptWithPrivateKey

func DecryptWithPrivateKey(encrypted string, privateKey *rsa.PrivateKey) (res []byte, err error)

func Dup

func Dup(s string) string

func Encrypt

func Encrypt(data string) (string, error)

func EncryptWithPublicKey

func EncryptWithPublicKey(data []byte, publicKey *rsa.PublicKey) (res string, err error)

func Execute

func Execute(ctx context.Context, command string, args ...string) ([]byte, error)

func HC

func HC() *http.Client

HC returns a singleton http client, initialize only once

func IsUnixSockFile

func IsUnixSockFile(filename string) bool

IsUnixSockFile check if specified file is local unix socket file. Unlike named pipes which allow only unidirectional data flow, sockets are fully duplex-capable. A UNIX socket is marked with an s as the first letter of the mode string, e.g. srwxrwxrwx /tmp/.X11-unix/X0

func LoadGroups

func LoadGroups(data []byte) (groups types.Groups, err error)

func LoadUsers

func LoadUsers(data []byte) (users types.Users, err error)

func MD5

func MD5(args ...any) string

func ParseContainerIDByPid

func ParseContainerIDByPid(pid int) (containerId string, err error)

func Recycle

func Recycle(buf *bytes.Buffer)

func SHA1

func SHA1(args ...any) string

func SHA256

func SHA256(args ...any) string

func Uname

func Uname() (*types.Utsname, error)

Types

type BufferSize

type BufferSize int
const (
	BufferSize1K BufferSize = 0x1 << (10 + iota)
	BufferSize2K
	BufferSize4K
	BufferSize8K
	BufferSize16K
	BufferSizeMax
)

Jump to

Keyboard shortcuts

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