Documentation ¶
Index ¶
- Constants
- Variables
- func CheckPort(port int) bool
- func ChickIsDir(path string) bool
- func Compare(a, b string) bool
- func Decode(in []byte, charset string) ([]byte, error)
- func DecodeFileName(headerName string, ZipFilenameEncoding string) string
- func DeleteFileIfExist(filePath string) error
- func DetectUTF8(s string) (valid, require bool)
- func FileExists(path string) bool
- func GbkToUtf8(unknowString string) (string, error)
- func GenerateImage(text string) ([]byte, error)
- func GetAbsPath(path string) string
- func GetAuthor(input string) string
- func GetContentTypeByFileName(fileName string) (contentType string)
- func GetEncoding(charset string) (encoding.Encoding, bool)
- func GetFreePort() (int, error)
- func GetIPList() (IPList []string, err error)
- func GetImageDataBlurHash(loadedImage []byte, components int) string
- func GetImageDataBlurHashImage(loadedImage []byte, components int) []byte
- func GetMainName(filename string) string
- func GetOutboundIP() net.IP
- func GuessText(unknowString string) (string, error)
- func ImageAutoCrop(loadedImage []byte, energyThreshold float32) []byte
- func ImageGray(loadedImage []byte) []byte
- func ImageResize(loadedImage []byte, width int, height int) []byte
- func ImageResizeByHeight(loadedImage []byte, height int) []byte
- func ImageResizeByMaxHeight(loadedImage []byte, maxHeight int) ([]byte, error)
- func ImageResizeByMaxWidth(loadedImage []byte, maxWidth int) ([]byte, error)
- func ImageResizeByWidth(loadedImage []byte, width int) []byte
- func ImageThumbnail(loadedImage []byte, width int, height int) []byte
- func IsAbsPath(aPath string) bool
- func IsDir(path string) bool
- func IsExist(path string) bool
- func IsFile(path string) bool
- func IsImageFile(path string) bool
- func IsZipFile(filepath string) bool
- func MD5file(fName string) string
- func MimeType(path string) (mime string)
- func OpenBrowser(uri string)
- func PathExists(path string) bool
- func PrintAllReaderURL(Port int, OpenBrowserFlag bool, PrintAllPossibleQRCode bool, ServerHost string, ...)
- func PrintQRCode(text string)
- func ReaderMimeType(r io.Reader) (mime string)
- func RemoveExtension(filename string) string
- func ShiftjisToUtf8(unknowString string) (string, error)
- func Sort(l []string)
- func ToGBK(str string) (string, error)
- func ToShiftJIS(str string) (string, error)
- func TrackTIme(pre time.Time) time.Duration
- type ServerStatus
- type SystemStatus
Constants ¶
const (
// MimeSniffLen sniff Length, use for detect file mime type
MimeSniffLen = 512
)
ReaderMimeType get the io.Reader mimeType
Usage:
file, err := os.Open(filepath) if err != nil { return } mime := ReaderMimeType(file)
Variables ¶
var ( DefaultDirPerm os.FileMode = 0775 DefaultFilePerm os.FileMode = 0665 OnlyReadFilePerm os.FileMode = 0444 )
perm for create dir or file
var ( // DefaultFileFlags for create and write DefaultFileFlags = os.O_CREATE | os.O_WRONLY | os.O_APPEND // OnlyReadFileFlags open file for read OnlyReadFileFlags = os.O_RDONLY )
var ( DirExist = IsDir FileExist = IsFile PathExist = PathExists )
alias methods
var ImageMimeTypes = map[string]string{
"bmp": "image/bmp",
"gif": "image/gif",
"ief": "image/ief",
"jpg": "image/jpeg",
"jpeg": "image/jpeg",
"png": "image/png",
"svg": "image/svg+xml",
"ico": "image/x-icon",
"webp": "image/webp",
}
ImageMimeTypes refer net/http package
Functions ¶
func Compare ¶
Compare returns true if the first string precedes the second one according to natural order
func DecodeFileName ¶
func DetectUTF8 ¶
DetectUTF8 检测 s 是否为有效的 UTF-8 字符串,以及该字符串是否必须被视为 UTF-8 编码(即,不兼容CP-437、ASCII 或任何其他常见编码)。 来自: go\src\archive\zip\reader.go
func FileExists ¶
FileExists reports whether the named file or directory exists.
func GenerateImage ¶
GenerateImage 创建一个带有动态文字的JPEG图片,并返回其[]byte形式
func GetContentTypeByFileName ¶
GetContentTypeByFileName https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
func GetImageDataBlurHash ¶
GetImageDataBlurHash 获取图片的BlurHash
func GetImageDataBlurHashImage ¶
GetImageDataBlurHashImage 获取图片的BlurHash图
func GetOutboundIP ¶
GetOutboundIP 获取本机的首选出站IP Get preferred outbound ip of this machine
func ImageAutoCrop ¶
ImageAutoCrop 自动裁白边
func ImageResize ¶
ImageResize 重设图片分辨率
func ImageResizeByHeight ¶
ImageResizeByHeight 根据一个固定 Height 缩放图片
func ImageResizeByMaxHeight ¶
ImageResizeByMaxHeight 设定一个图片高度上限,大于这个高度就缩放
func ImageResizeByMaxWidth ¶
ImageResizeByMaxWidth 设定一个图片宽度上限,大于这个宽度就缩放
func ImageResizeByWidth ¶
ImageResizeByWidth 根据一个固定宽度缩放图片
func ImageThumbnail ¶
ImageThumbnail 根据设定的图片大小,剪裁图片
func IsZipFile ¶
IsZipFile check is zip file. from https://blog.csdn.net/wangshubo1989/article/details/71743374
func OpenBrowser ¶
func OpenBrowser(uri string)
func PathExists ¶
PathExists reports whether the named file or directory exists.
func PrintAllReaderURL ¶
func PrintAllReaderURL(Port int, OpenBrowserFlag bool, PrintAllPossibleQRCode bool, ServerHost string, DisableLAN bool, enableTls bool, etcStr string)
PrintAllReaderURL 打印阅读链接
func PrintQRCode ¶
func PrintQRCode(text string)
func ReaderMimeType ¶
func ShiftjisToUtf8 ¶
func ToShiftJIS ¶
ToShiftJIS Convert a string encoding from UTF-8 to ShiftJIS
Types ¶
type ServerStatus ¶
type ServerStatus struct { ServerName string //服务器描述 ServerHost string // ServerPort int // NumberOfBooks int //当前拥有的书籍总数 NumberOfOnLineUser int //TODO:在线用户数 NumberOfOnLineDevices int //TODO:在线设备数 SupportUploadFile bool // ClientIP string //客户端IP OSInfo SystemStatus //系统信息 }
ServerStatus 服务器当前状况
func GetAllServerInfo ¶
func GetServerInfo ¶
type SystemStatus ¶
type SystemStatus struct { //CPU相关 CPUNumLogical int `json:"cpu_num_logical_total"` CPUNumPhysical int `json:"cpu_num_physical"` CPUUsedPercent float64 `json:"cpu_used_percent"` //内存相关 MemoryTotal uint64 `json:"memory_total"` MemoryFree uint64 `json:"memory_free"` MemoryUsedPercent float64 `json:"memory_used_percent"` //设备描述 Description string `json:"description"` }
SystemStatus Documentation: https://pkg.go.dev/github.com/shirou/gopsutil 获取服务器当前状况
func GetSystemStatus ¶
func GetSystemStatus() SystemStatus