1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

fix: fix code in UnZip demo

This commit is contained in:
dudaodong
2024-10-25 11:14:15 +08:00
parent a4e89bd7c1
commit 840ea8f3c5
3 changed files with 29 additions and 12 deletions

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -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() {