我正在尝试使用以下方法获取公开可用文件的内容ioutil.ReadFile(),但找不到该文件:panic: open http://www.pdf995.com/samples/pdf.pdf: No such file or directory
这是我的代码:
// Reading and writing files are basic tasks needed for
// many Go programs. First we'll look at some examples of
// reading files.
package main
import (
"fmt"
"io/ioutil"
)
// Reading files requires checking most calls for errors.
// This helper will streamline our error checks below.
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
fileInUrl, err := ioutil.ReadFile("http://www.pdf995.com/samples/pdf.pdf")
if err != nil {
panic(err)
}
fmt.Printf("HERE --- fileInUrl: %+v", fileInUrl)
}
这是一个游乐场示例
倚天杖
相关分类