Documentation ¶
Index ¶
- Constants
- Variables
- func CheckExists(path string) bool
- 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 DetectUTF8(s string) (valid, require bool)
- func FileExists(path string) bool
- func GbkToUtf8(unknowString string) (string, error)
- func GetAbsPath(path string) string
- func GetAuthor(input string) (string, bool)
- 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 LoggerToFile(LogFilePath string, LogFileName string) gin.HandlerFunc
- func LoggerToStdout() gin.HandlerFunc
- 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 ShiftjisToUtf8(unknowString string) (string, error)
- func Sort(l []string)
- func ToGBK(str string) (string, error)
- func ToShiftJIS(str string) (string, error)
- 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 ¶ added in v0.7.1
Compare returns true if the first string precedes the second one according to natural order
func DecodeFileName ¶
func DetectUTF8 ¶ added in v0.7.1
DetectUTF8 检测 s 是否为有效的 UTF-8 字符串,以及该字符串是否必须被视为 UTF-8 编码(即,不兼容CP-437、ASCII 或任何其他常见编码)。 来自: go\src\archive\zip\reader.go
func FileExists ¶ added in v0.9.1
FileExists reports whether the named file or directory exists.
func GetContentTypeByFileName ¶ added in v0.7.1
GetContentTypeByFileName https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
func GetImageDataBlurHash ¶ added in v0.7.1
GetImageDataBlurHash 获取图片的BlurHash
func GetImageDataBlurHashImage ¶ added in v0.7.1
GetImageDataBlurHashImage 获取图片的BlurHash图
func GetOutboundIP ¶
GetOutboundIP 获取本机的首选出站IP Get preferred outbound ip of this machine
func ImageAutoCrop ¶ added in v0.7.1
ImageAutoCrop 自动裁白边
func ImageResize ¶ added in v0.7.1
ImageResize 重设图片分辨率
func ImageResizeByHeight ¶ added in v0.7.1
ImageResizeByHeight 根据一个固定 Height 缩放图片
func ImageResizeByMaxHeight ¶ added in v0.7.1
ImageResizeByMaxHeight 设定一个图片高度上限,大于这个高度就缩放
func ImageResizeByMaxWidth ¶ added in v0.7.1
ImageResizeByMaxWidth 设定一个图片宽度上限,大于这个宽度就缩放
func ImageResizeByWidth ¶ added in v0.7.1
ImageResizeByWidth 根据一个固定宽度缩放图片
func ImageThumbnail ¶ added in v0.7.2
ImageThumbnail 根据设定的图片大小,剪裁图片
func IsImageFile ¶ added in v0.9.1
IsImageFile check file is image file.
func IsZipFile ¶ added in v0.9.1
IsZipFile check is zip file. from https://blog.csdn.net/wangshubo1989/article/details/71743374
func LoggerToFile ¶
func LoggerToFile(LogFilePath string, LogFileName string) gin.HandlerFunc
LoggerToFile log功能,现在还没做完
func LoggerToStdout ¶
func LoggerToStdout() gin.HandlerFunc
func PathExists ¶ added in v0.9.1
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 ¶ added in v0.9.1
func ShiftjisToUtf8 ¶ added in v0.9.5
func ToShiftJIS ¶ added in v0.7.1
ToShiftJIS Convert a string encoding from UTF-8 to ShiftJIS
Types ¶
type SystemStatus ¶ added in v0.7.1
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 服务器当前状况
func GetSystemStatus ¶ added in v0.7.1
func GetSystemStatus() SystemStatus