mirror of
https://github.com/duke-git/lancet.git
synced 2026-03-01 00:35:28 +08:00
fix: fix goline error
This commit is contained in:
@@ -242,7 +242,10 @@ func ExampleEncodeByte() {
|
|||||||
func ExampleDecodeByte() {
|
func ExampleDecodeByte() {
|
||||||
var obj string
|
var obj string
|
||||||
byteData := []byte{6, 12, 0, 3, 97, 98, 99}
|
byteData := []byte{6, 12, 0, 3, 97, 98, 99}
|
||||||
DecodeByte(byteData, &obj)
|
err := DecodeByte(byteData, &obj)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println(obj)
|
fmt.Println(obj)
|
||||||
|
|
||||||
|
|||||||
@@ -1442,7 +1442,7 @@ func main() {
|
|||||||
|
|
||||||
### <span id="Union">Union</span>
|
### <span id="Union">Union</span>
|
||||||
|
|
||||||
<p>合并多个切片.</p>
|
<p>合并多个切片</p>
|
||||||
|
|
||||||
<b>函数签名:</b>
|
<b>函数签名:</b>
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ func ExampleCreateDir() {
|
|||||||
|
|
||||||
result1 := IsExist(dirPath)
|
result1 := IsExist(dirPath)
|
||||||
|
|
||||||
CreateDir(dirPath)
|
err := CreateDir(dirPath)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
result2 := IsExist(dirPath)
|
result2 := IsExist(dirPath)
|
||||||
|
|
||||||
@@ -75,8 +78,10 @@ func ExampleRemoveFile() {
|
|||||||
CreateFile(srcFile)
|
CreateFile(srcFile)
|
||||||
|
|
||||||
copyFile := "./text_copy.txt"
|
copyFile := "./text_copy.txt"
|
||||||
CopyFile(srcFile, copyFile)
|
err := CopyFile(srcFile, copyFile)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
file, err := os.Open(copyFile)
|
file, err := os.Open(copyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -102,7 +107,10 @@ func ExampleReadFileToString() {
|
|||||||
f, _ := os.OpenFile(fname, os.O_WRONLY|os.O_TRUNC, 0777)
|
f, _ := os.OpenFile(fname, os.O_WRONLY|os.O_TRUNC, 0777)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
f.WriteString("hello world")
|
_, err := f.WriteString("hello world")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
content, _ := ReadFileToString(fname)
|
content, _ := ReadFileToString(fname)
|
||||||
|
|
||||||
@@ -121,12 +129,17 @@ func ExampleClearFile() {
|
|||||||
f, _ := os.OpenFile(fname, os.O_WRONLY|os.O_TRUNC, 0777)
|
f, _ := os.OpenFile(fname, os.O_WRONLY|os.O_TRUNC, 0777)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
f.WriteString("hello world")
|
_, err := f.WriteString("hello world")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
content1, _ := ReadFileToString(fname)
|
content1, _ := ReadFileToString(fname)
|
||||||
|
|
||||||
ClearFile(fname)
|
err = ClearFile(fname)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
content2, _ := ReadFileToString(fname)
|
content2, _ := ReadFileToString(fname)
|
||||||
|
|
||||||
os.Remove(fname)
|
os.Remove(fname)
|
||||||
@@ -146,7 +159,10 @@ func ExampleReadFileByLine() {
|
|||||||
f, _ := os.OpenFile(fname, os.O_WRONLY|os.O_TRUNC, 0777)
|
f, _ := os.OpenFile(fname, os.O_WRONLY|os.O_TRUNC, 0777)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
f.WriteString("hello\nworld")
|
_, err := f.WriteString("hello\nworld")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
content, _ := ReadFileByLine(fname)
|
content, _ := ReadFileByLine(fname)
|
||||||
|
|
||||||
@@ -171,7 +187,10 @@ func ExampleZip() {
|
|||||||
CreateFile(srcFile)
|
CreateFile(srcFile)
|
||||||
|
|
||||||
zipFile := "./test.zip"
|
zipFile := "./test.zip"
|
||||||
Zip(srcFile, zipFile)
|
err := Zip(srcFile, zipFile)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
result := IsExist(zipFile)
|
result := IsExist(zipFile)
|
||||||
|
|
||||||
@@ -187,7 +206,11 @@ func ExampleZip() {
|
|||||||
func ExampleUnZip() {
|
func ExampleUnZip() {
|
||||||
fname := "./test.txt"
|
fname := "./test.txt"
|
||||||
file, _ := os.Create(fname)
|
file, _ := os.Create(fname)
|
||||||
file.WriteString("hello world")
|
|
||||||
|
_, err := file.WriteString("hello\nworld")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
f, _ := os.Open(fname)
|
f, _ := os.Open(fname)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|||||||
@@ -664,7 +664,10 @@ func ExampleSortByField() {
|
|||||||
{Name: "b", Age: 15},
|
{Name: "b", Age: 15},
|
||||||
{Name: "c", Age: 100}}
|
{Name: "c", Age: 100}}
|
||||||
|
|
||||||
SortByField(users, "Age", "desc")
|
err := SortByField(users, "Age", "desc")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println(users)
|
fmt.Println(users)
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,11 @@ func ExampleRemoveOsEnv() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExampleCompareOsEnv() {
|
func ExampleCompareOsEnv() {
|
||||||
SetOsEnv("foo", "abc")
|
err := SetOsEnv("foo", "abc")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
result1 := CompareOsEnv("foo", "abc")
|
result1 := CompareOsEnv("foo", "abc")
|
||||||
|
|
||||||
fmt.Println(result1)
|
fmt.Println(result1)
|
||||||
|
|||||||
Reference in New Issue
Block a user