Golang nil return value Cause panic

If the return object doc is nil, doc.ABC() will be panic.


url := "https://example.com"
doc, err := getDoc(url)
if err != nil {
	log.Println(err)
	continue
	// or handle this or return
}

doc.ABC()
// if doc is nil, this will be panic and the program will quit immediately