Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Download2Memory ¶
Download2Memory https://stackoverflow.com/a/21351456/9935654
Example ¶
dataBytes, err := Download2Memory("https://www.google.com.tw/")
if err != nil {
panic(err)
}
fmt.Println(len(dataBytes) > 0)
Output: true
func DownloadFile ¶
DownloadFile https://stackoverflow.com/a/33853856/9935654
Example ¶
Output support string or os.File both OK!
// Output type: string
if err := DownloadFile("temp.html", "https://www.google.com.tw/"); err != nil {
panic(err)
}
// Output type: writer
writer, err := os.Create("temp2.html")
if err != nil {
panic(err)
}
if err = DownloadFile(writer, "https://www.google.com.tw/"); err != nil {
panic(err)
}
func DownloadFileWithTimeout ¶ added in v2.2.0
func DownloadFileWithTimeout[T *os.File | string](out T, url string, timeout time.Duration) (err error)
Example ¶
// Output type: string
if err := DownloadFileWithTimeout("temp.html", "https://www.google.com.tw/", 5*time.Second); err != nil {
panic(err)
}
// Output type: writer
writer, err := os.Create("temp2.html")
if err != nil {
panic(err)
}
if err = DownloadFileWithTimeout(writer, "https://www.google.com.tw/", 5*time.Second); err != nil {
panic(err)
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.