Documentation ¶
Index ¶
- Constants
- func AbsPath(path string, create bool) (string, error)
- func Characters(data []byte) int
- func CharactersForFile(filename string) (int, error)
- func CleanBlankLines(data []byte) []byte
- func CleanBlankLinesForFile(filename string) ([]byte, error)
- func CleanSpecificContentLines(data []byte, findStr string) []byte
- func CleanSpecificContentLinesForFile(filename string, findStr string) ([]byte, error)
- func ContentDispositionFilename() func(val string) string
- func Copy(src string, dst string, ops ...Option) error
- func CreateFile(filename string, data []byte, ops ...Option) (string, error)
- func CreateFilename(filename, extension string, ops ...Option) string
- func CreateZIPFileWithFilename(source string) (string, error)
- func DirNotExists(path string) bool
- func DownloadFile(resp http.ResponseWriter, path string) error
- func FilenameTrimPrefix(filename, prefix string) string
- func GetContentWithRegularExpression(str, pattern string, ops ...Option) ([]string, error)
- func GetFileContentBytesWithEmbedFS(fs embed.FS, filename string) ([]byte, error)
- func GetFileContentStringSliceWithBuffer(buffer *bytes.Buffer, ops ...Option) ([]string, error)
- func GetFileContentStringSliceWithEmbedFS(fs embed.FS, filename string, ops ...Option) ([]string, error)
- func GetFileContentStringSliceWithFilename(filename string, ops ...Option) ([]string, error)
- func GetFileExtension(filename string, ops ...Option) string
- func GetFileOrDirectoryName(path string) (string, bool, error)
- func GetFilePathWithFileSystemPath(baseDir string, ops ...Option) (string, error)
- func GetGOPATH() string
- func GetGOPATHProjectSource() string
- func GetResponseHeader(resp http.ResponseWriter, field string) string
- func GetResponseHeaderFunc(resp http.ResponseWriter, field string, process func(val string) string) string
- func InSlice(source []interface{}, find interface{}) bool
- func IsDir(path string) (bool, error)
- func IsFile(filename string) (bool, error)
- func IsNotExists(path string) bool
- func IsNotExistsWithEmbedFS(embeds embed.FS, path string) bool
- func LastDirName(filename string) string
- func Lines(data []byte) int
- func LinesForFile(filename string) (int, error)
- func MarkContentPrefixClear(data []byte, mark string, ops ...Option) []byte
- func MarkContentSuffixClear(data []byte, mark string, ops ...Option) []byte
- func MkdirAll(path string) error
- func MustGetFilePathWithFileSystemPath(baseDir string, ops ...Option) string
- func NotExistsMkdir(path string) error
- func NotExistsMkdirAll(path string) error
- func ReadDir(path string, result []string) ([]string, error)
- func RuntimeMasterDir() string
- func Touch(filename string) error
- func Truncate(filename string, size int64) error
- func UploadFileForMultipartFields(values map[string]interface{}) (contentType string, buffer bytes.Buffer, err error)
- func UploadIsAllowMIMEWithFormFile(request *http.Request, key string, allows []string) (bool, error)
- func WriteDir(dst string, files []string, ops ...Option) error
- type FileExtension
- type FileSystemPath
- type Option
- func WithIgnoreBlankLine(ignored bool) Option
- func WithOriginalFileNameTrimPrefix(str string) Option
- func WithSpecificBaseDir(baseDir string) Option
- func WithSpecificContainsMarkString(contains bool) Option
- func WithSpecificFileExtension(extension FileExtension) Option
- func WithSpecificFileExtensionContainsDot(containsdot bool) Option
- func WithSpecificFileSystemPath(path FileSystemPath) Option
- func WithSpecificTrimOriginalFileExtension(trim bool) Option
- type VersionGithub
Constants ¶
const (
FileSystemOfGOPATH = "GOPATH"
)
const (
// GlobalSeparatorWithFileName File name separator.
GlobalSeparatorWithFileName = "."
)
const (
ZIPExtension = "zip"
)
Variables ¶
This section is empty.
Functions ¶
func AbsPath ¶ added in v1.1.8
AbsPath Checks whether a directory is an absolute path and can be created by creating a path that does not exist
func CharactersForFile ¶
CharactersForFile Count the number of data characters
func CleanBlankLines ¶
CleanBlankLines clean blank lines with file.
func CleanBlankLinesForFile ¶
CleanBlankLinesForFile clean blank lines with file.
func CleanSpecificContentLines ¶
CleanSpecificContentLines clean specific content lines.
func CleanSpecificContentLinesForFile ¶
CleanSpecificContentLinesForFile clean specific content lines for file.
func ContentDispositionFilename ¶
ContentDispositionFilename Gets filename for response header Content-Disposition. Header such as Content-Disposition: attachment; filename="helloshaohua.txt"
func CreateFile ¶
CreateFile Create new file, your can specific multiple options.
func CreateFilename ¶
CreateFilename Create the filename.
func CreateZIPFileWithFilename ¶
CreateZIPFileWithFilename CreateZIPFile Create ZIP file, return the storage path and error. source parameter specifies a file or directory.
func DirNotExists ¶ added in v1.0.5
DirNotExists Check whether the specified file path directory does not exists.
func DownloadFile ¶
func DownloadFile(resp http.ResponseWriter, path string) error
DownloadFile will write download file into the HTTP response body.
func FilenameTrimPrefix ¶ added in v1.0.5
FilenameTrimPrefix Trim the filename prefix.
func GetContentWithRegularExpression ¶ added in v1.0.9
GetContentWithRegularExpression Get the string content into slice's string, using a regular expression.
func GetFileContentBytesWithEmbedFS ¶ added in v1.1.4
GetFileContentBytesWithEmbedFS Get file content bytes slice with embed filesystem.
func GetFileContentStringSliceWithBuffer ¶ added in v1.1.6
GetFileContentStringSliceWithBuffer Get file content string slice with bytes buffer
func GetFileContentStringSliceWithEmbedFS ¶ added in v1.1.4
func GetFileContentStringSliceWithEmbedFS(fs embed.FS, filename string, ops ...Option) ([]string, error)
GetFileContentStringSliceWithEmbedFS Get file content string slice with embed filesystem.
func GetFileContentStringSliceWithFilename ¶ added in v1.1.4
GetFileContentStringSliceWithFilename Get the file contents as a string for slice.
func GetFileExtension ¶
GetFileExtension Gets the file extension.
func GetFileOrDirectoryName ¶ added in v1.1.1
GetFileOrDirectoryName Gets the file or directory name.
func GetFilePathWithFileSystemPath ¶ added in v1.1.0
GetFilePathWithFileSystemPath Get a file path with filesystem path.
func GetGOPATH ¶
func GetGOPATH() string
GetGOPATH Gets the current operating system GOPATH from environment.
func GetGOPATHProjectSource ¶
func GetGOPATHProjectSource() string
GetGOPATHProjectSource Gets the current operating system GOPATH/src from environment and filesystem.
func GetResponseHeader ¶
func GetResponseHeader(resp http.ResponseWriter, field string) string
GetResponseHeader Gets response header field value.
func GetResponseHeaderFunc ¶
func GetResponseHeaderFunc(resp http.ResponseWriter, field string, process func(val string) string) string
GetResponseHeaderFunc GetResponseHeader Gets response header field value, processing of response field values by attaching custom functions.
func IsNotExists ¶
IsNotExists check whether the target file or directory exists. Return FALSE if the file exists, TRUE otherwise.
func IsNotExistsWithEmbedFS ¶ added in v1.1.1
IsNotExistsWithEmbedFS check whether the target file or directory exists with embed.FS. Return FALSE if the file exists, TRUE otherwise.
func LastDirName ¶
LastDirName Gets filename the last directory name.
func LinesForFile ¶
LinesForFile Count the number of data rows from file.
func MarkContentPrefixClear ¶
MarkContentPrefixClear Mark content prefix clear.
func MarkContentSuffixClear ¶
MarkContentSuffixClear Mark content suffix clear.
func MustGetFilePathWithFileSystemPath ¶ added in v1.1.0
func NotExistsMkdir ¶
NotExistsMkdir detects whether the target folder exists. and if it does not, create the folder.
func NotExistsMkdirAll ¶ added in v1.1.8
NotExistsMkdirAll Check whether the directory exists and create it if it does not
func RuntimeMasterDir ¶
func RuntimeMasterDir() string
RuntimeMasterDir returns the root path corresponding to the current directory.
func Truncate ¶ added in v1.1.3
Truncate changes the size of the file. It does not change the I/O offset. If there is an error, it will be of type *PathError.
func UploadFileForMultipartFields ¶
func UploadFileForMultipartFields(values map[string]interface{}) (contentType string, buffer bytes.Buffer, err error)
UploadFileForMultipartFields Mock form upload file.
Types ¶
type FileExtension ¶
type FileExtension string
const ( FileExtensionWithImageOfJPEG FileExtension = "jpeg" FileExtensionWithImageOfPNG FileExtension = "png" FileExtensionWithImageOfGIF FileExtension = "gif" FileExtensionWithImageOfBMP FileExtension = "bmp" )
const ( FileExtensionWithOfficeOfExcel FileExtension = "xlsx" FileExtensionWithOfficeOfWord FileExtension = "docx" FileExtensionWithOfficeOfCSV FileExtension = "csv" )
const ( FileExtensionWithDocumentOfMarkdown FileExtension = "md" FileExtensionWithDocumentOfFileText FileExtension = "txt" )
func (FileExtension) String ¶
func (file FileExtension) String() string
type FileSystemPath ¶ added in v1.1.0
type FileSystemPath string
const ( AssetsSavePathForDatabase FileSystemPath = "static/assets/database" AssetsSavePathForExcel FileSystemPath = "static/assets/excel" AssetsSavePathForCSV FileSystemPath = "static/assets/csv" )
Assets files save path definition.
const GlobalDefaultDir FileSystemPath = "static"
func (FileSystemPath) String ¶ added in v1.1.0
func (p FileSystemPath) String() string
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithIgnoreBlankLine ¶ added in v1.0.5
WithIgnoreBlankLine Specify whether blank lines are ignored.
func WithOriginalFileNameTrimPrefix ¶ added in v1.0.5
WithOriginalFileNameTrimPrefix WithSpecificContainsMarkString Override the original value by trimPrefixStr string.
func WithSpecificBaseDir ¶
WithSpecificBaseDir Override the original value by specifying base directory.
func WithSpecificContainsMarkString ¶
WithSpecificContainsMarkString Override the original value by containsMarkString mark string.
func WithSpecificFileExtension ¶
func WithSpecificFileExtension(extension FileExtension) Option
WithSpecificFileExtension Override the original value by specifying file extension.
func WithSpecificFileExtensionContainsDot ¶
WithSpecificFileExtensionContainsDot Override the original value by specifying dot.
func WithSpecificFileSystemPath ¶ added in v1.1.7
func WithSpecificFileSystemPath(path FileSystemPath) Option
WithSpecificFileSystemPath Override the original value by specifying filepath.
func WithSpecificTrimOriginalFileExtension ¶
WithSpecificTrimOriginalFileExtension Override the original value by specifying trim.
type VersionGithub ¶ added in v1.1.2
type VersionGithub struct { Major string `json:"major"` Minor string `json:"minor"` Patch string `json:"patch"` }
VersionGithub Github version number format.
func GetVersion ¶ added in v1.1.2
func GetVersion(version string) (*VersionGithub, error)
GetVersion Get Github version information in version number format.
func (*VersionGithub) GetFullVersion ¶ added in v1.1.2
func (v *VersionGithub) GetFullVersion() string
GetFullVersion Get a full version string. Such as 1.16.6, will return 1.16.6
func (*VersionGithub) GetMinorVersion ¶ added in v1.1.2
func (v *VersionGithub) GetMinorVersion() string
GetMinorVersion Get a minor version string. Such as 1.16.6, will return 1.16
func (*VersionGithub) Join ¶ added in v1.1.2
func (v *VersionGithub) Join(element ...string) string
Join version section, default use dot.