Documentation ¶
Index ¶
- Constants
- 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 FileNotExists(filename string) bool
- func FilenameTrimPrefix(filename, prefix string) string
- func GetContentWithRegularExpression(str, pattern string, ops ...Option) ([]string, error)
- func GetFileContentWithFS(fs embed.FS, filename string) ([]byte, error)
- func GetFileContentWithStringSlice(filename string, ops ...Option) ([]string, error)
- func GetFileExtension(filename string, ops ...Option) string
- func GetFileOrDirName(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 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 ReadDir(path string, result []string) ([]string, error)
- func RuntimeMasterDir() string
- func Touch(filename string) 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 WithSpecificFSPath(path FileSystemPath) Option
- func WithSpecificFileExtension(extension FileExtension) Option
- func WithSpecificFileExtensionContainsDot(containsdot bool) Option
- func WithSpecificTrimOriginalFileExtension(trim bool) Option
Constants ¶
const (
FileSystemOfGOPATH = "GOPATH"
)
const (
// GlobalSeparatorWithFileName File name separator.
GlobalSeparatorWithFileName = "."
)
const (
ZIPExtension = "zip"
)
Variables ¶
This section is empty.
Functions ¶
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 FileNotExists ¶ added in v1.0.5
FileNotExists Check file is exists.
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 GetFileContentWithFS ¶
GetFileContentWithFS Get file content with embed filesystem.
func GetFileContentWithStringSlice ¶ added in v1.0.5
GetFileContentWithStringSlice Get the file contents as a string for slice.
func GetFileExtension ¶
GetFileExtension Gets the file extension.
func GetFileOrDirName ¶ added in v1.0.5
GetFileOrDirName 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 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 RuntimeMasterDir ¶
func RuntimeMasterDir() string
RuntimeMasterDir returns the root path corresponding to the current directory.
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 WithSpecificFSPath ¶
func WithSpecificFSPath(path FileSystemPath) Option
WithSpecificFSPath Override the original value by specifying filepath.
func WithSpecificFileExtension ¶
func WithSpecificFileExtension(extension FileExtension) Option
WithSpecificFileExtension WithSpecificFSPath Override the original value by specifying filepath.
func WithSpecificFileExtensionContainsDot ¶
WithSpecificFileExtensionContainsDot Override the original value by specifying dot.
func WithSpecificTrimOriginalFileExtension ¶
WithSpecificTrimOriginalFileExtension WithSpecificFileTrimOriginalExtension Override the original value by specifying dot.