ahmdrz / goinsta

Unofficial Instagram API written in Golang
MIT License
895 stars 247 forks source link

Runtime error #330

Open cbolanos79 opened 3 years ago

cbolanos79 commented 3 years ago

I tried a simple example but got an error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x696ec8]

goroutine 1 [running]:
gopkg.in/ahmdrz/goinsta%2ev2.(*Instagram).Export(0xc00013e000, 0x728090, 0xa, 0x0, 0xc00013e000)
    /go/src/gopkg.in/ahmdrz/goinsta.v2/goinsta.go:191 +0xc8
main.main()
    /home/go/main.go:16 +0x65
exit status 2

source code:

package main

import (
  //"fmt"

  "gopkg.in/ahmdrz/goinsta.v2"
)

func main() {
  insta := goinsta.New("myuser", "")

  // Export your configuration
  // after exporting you can use Import function instead of New function.
  // insta, err := goinsta.Import("~/.goinsta")
  // it's useful when you want use goinsta repeatedly.
  insta.Export("~/.goinsta")

  //...
}

Using golang on docker Go version:

root@f4d5f0d22daf:/home/go# go version
go version go1.15.6 linux/amd64
renanberto commented 3 years ago

Hello dude, I found this error and fix with it:

package main

import (
    "fmt"

    "github.com/ahmdrz/goinsta/v2"
)

func main() {
    insta := goinsta.New("USER", "PASSWORD")

    if err := insta.Login(); err != nil {
        fmt.Println(err)
    }

    insta.Export("~/.goinsta")
}
alimkoca commented 3 years ago

Thanks worked for me