golibs

package module
v0.0.0-...-d66ce5c Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: MIT Imports: 19 Imported by: 0

README

golibs

封装自己找到的golang好用的方法。 不定期更新中。

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSingleton = errors.New("singleton process")
)

Functions

func AesDecrypt

func AesDecrypt(cryptEd string, key, iv []byte) ([]byte, error)

func BytesToString

func BytesToString(b []byte) string

由于共用内存,[]byte改变时string也会变

func GenRsaKey

func GenRsaKey(bits int, private, public string) error

func IsFilePathExists

func IsFilePathExists(path string, isFile bool) error

判断文件或目录存在且类型正确

func Md5sum

func Md5sum(s string, isFile bool) (string, error)

func PKCS5Padding

func PKCS5Padding(cipherText []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func RsaDecrypt

func RsaDecrypt(cipherText, privateKey []byte) ([]byte, error)

解密

func RsaEncrypt

func RsaEncrypt(origData, publicKey []byte) ([]byte, error)

加密

func SingletonFile

func SingletonFile(path string) error

通过加锁文件实现进程单例 返回ErrSingleton表示文件被锁,已有进程在运行

func SingletonTcp

func SingletonTcp(port int) error

通过监听TCP端口实现进程单例

func StringToBytes

func StringToBytes(s string) []byte

由于共用内存,转换后的[]byte不可写

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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