I get a "panic: runtime error: invalid memory address or nil pointer dereference" when running the following code. I do not understand why and cant seem to catch the error from the io.WriteString(w, s) where I believe the problem resides. Can anybody point me in the right direction?
package main
import(
"io"
"fmt"
)
func main() {
s := "hei"
var w io.Writer
_, err := io.WriteString(w, s)
if err != nil{
fmt.Println(s)
}
}