如果你比较急那么解决问题之后再看这段话,建议看一下:
When Read encounters an error or EOF (end-of-file) after successfully reading n > 0 bytes, it returns the number of bytes read.
In general, Reader will return a non-zero byte number n, if n = len(p) bytes are returned by Read from the end of the input source.
Read may return err == EOF or err == nil. And then Read() should return (n:0, err:EOF).The caller should process the returned data first before considering the error. Doing so correctly handles I/O errors that occur after reading some bytes, while allowing EOF to occur.
该问题并非不正常,出现时大多能正常返回数据,处理方式:
...省略部分代码...
response, err := ()
if err != nil {
if ((), "unexpected EOF") && len(response) != 0 {
("when read response: %s, will parse to YAML's []byte.", ())
goto pars
}
return nil, err
}
pars:
//执行你的下一步操作即可
bytes, err := (response)
return bytes, err
即,以合适的方式取你的数据即可。