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

feat: move new functions from v2 version

This commit is contained in:
dudaodong
2023-04-19 15:49:07 +08:00
parent 6576b1f0cb
commit ee44526d9e
26 changed files with 2105 additions and 119 deletions

View File

@@ -45,6 +45,8 @@ import (
- [HttpPut<sup>Deprecated</sup>](#HttpPut)
- [HttpPatch<sup>Deprecated</sup>](#HttpPatch)
- [ParseHttpResponse](#ParseHttpResponse)
- [UploadFile](#UploadFile)
- [DownloadFile](#DownloadFile)
- [IsPingConnected](#IsPingConnected)
- [IsTelnetConnected](#IsTelnetConnected)
@@ -552,7 +554,7 @@ package main
import (
"fmt"
"github.com/duke-git/lancet/v2/netutil"
"github.com/duke-git/lancet/netutil"
)
func main() {
@@ -864,6 +866,62 @@ func main() {
}
```
### <span id="UploadFile">UploadFile</span>
<p>将文件上传指定的server地址。</p>
<b>函数签名:</b>
```go
func UploadFile(filepath string, server string) (bool, error)
```
<b>例子:</b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/netutil"
)
func main() {
ok, err := netutil.UploadFile("./a.jpg", "http://www.xxx.com/bucket/test")
fmt.Println(ok)
fmt.Println(err)
}
```
### <span id="DownloadFile">DownloadFile</span>
<p>从指定的server地址下载文件。</p>
<b>函数签名:</b>
```go
func DownloadFile(filepath string, url string) error
```
<b>例子:</b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/netutil"
)
func main() {
ok, err := netutil.DownloadFile("./", "http://www.xxx.com/a.jpg")
fmt.Println(ok)
fmt.Println(err)
}
```
### <span id="IsPingConnected">IsPingConnected</span>
<p>检查能否ping通主机。</p>