I'm trying to get an io.Reader back from this weather it's a link or a path I'm given. For some context I'm using flags
func getString(link, path string) (io.Reader, error) {
var dick io.ReadWriter
if link != "" {
resp, err := http.Get(link)
if err != nil {
return nil, err
}
io.Copy(dick, resp.Body)
}
if path != "" {
file, err := os.Open(path)
if err != nil {
return nil, err
}
io.Copy(dick, file)
}
return dick, nil
}
and boom
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x46e949]
this bad boy comes along