diff --git a/docs/api/packages/fileutil.md b/docs/api/packages/fileutil.md index 937dfd9..762cd71 100644 --- a/docs/api/packages/fileutil.md +++ b/docs/api/packages/fileutil.md @@ -560,7 +560,7 @@ import ( ) func main() { - err := fileutil.Zip("./test.zip", "./unzip/test.txt") + err := fileutil.UnZip("./test.zip", "./test.txt") if err != nil { fmt.Println(err) } diff --git a/docs/en/api/packages/fileutil.md b/docs/en/api/packages/fileutil.md index e52e05c..54b7686 100644 --- a/docs/en/api/packages/fileutil.md +++ b/docs/en/api/packages/fileutil.md @@ -560,7 +560,7 @@ import ( ) func main() { - err := fileutil.Zip("./test.zip", "./unzip/test.txt") + err := fileutil.UnZip("./test.zip", "./test.txt") if err != nil { fmt.Println(err) } diff --git a/fileutil/file_example_test.go b/fileutil/file_example_test.go index b0fc026..1d53a4c 100644 --- a/fileutil/file_example_test.go +++ b/fileutil/file_example_test.go @@ -192,6 +192,27 @@ func ExampleListFileNames() { // [assert.go assert_test.go error_join.go] } +func ExampleMiMeType() { + fname := "./test.txt" + file, _ := os.Create(fname) + + _, err := file.WriteString("hello\nworld") + if err != nil { + return + } + + f, _ := os.Open(fname) + defer f.Close() + + mimeType := MiMeType(f) + fmt.Println(mimeType) + + os.Remove(fname) + + // Output: + // application/octet-stream +} + func ExampleZip() { srcFile := "./test.txt" CreateFile(srcFile) @@ -214,24 +235,20 @@ func ExampleZip() { } func ExampleUnZip() { - fname := "./test.txt" - file, _ := os.Create(fname) + zipFile := "./testdata/file.go.zip" - _, err := file.WriteString("hello\nworld") + err := UnZip(zipFile, "./testdata") if err != nil { return } - f, _ := os.Open(fname) - defer f.Close() + exist := IsExist("./testdata/file.go") + fmt.Println(exist) - mimeType := MiMeType(f) - fmt.Println(mimeType) - - os.Remove(fname) + os.Remove("./testdata/file.go") // Output: - // application/octet-stream + // true } func ExampleZipAppendEntry() {