Closed mlunax closed 1 year ago
My code:
package main import ( "net/http" "os" "github.com/gocolly/colly/v2" ) func main() { dir, err := os.Getwd() if err != nil { panic(err) } t := &http.Transport{} t.RegisterProtocol("file", http.NewFileTransport(http.Dir(os.Args[0]))) c := colly.NewCollector() c.WithTransport(t) c.OnXML("PRODUCTDATA", func(element *colly.XMLElement) { println(element) }) path := "file://" + dir + "/cat.xml" println(path) c.Visit(path) c.Wait() println(err.Error()) }
go.mod:
go.mod
module main go 1.14 require github.com/gocolly/colly/v2 v2.1.1-0.20230517145056-ea4b1dd0e5e6 // indirect
error:
error
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x894677] goroutine 1 [running]: main.main() /tmp/main.go:30 +0x1bc exit status 2
Could you please do some debugging before wasting other's time?
My code:
go.mod
:error
: