nicklaw5/helix

Segfault on any request

mkhan45 opened this issue · 2 comments

When I try to use GetClips with a specified start time and end time, I get a segfault:

  startTime := time.Now().Add(time.Duration(-1) * time.Hour)
  endTime := time.Now()

  resp, err := twitchClient.GetClips(&helix.ClipsParams {
     BroadcasterID: accountID,
     First: 5,
     StartedAt: helix.Time{ Time: startTime },
     EndedAt: helix.Time{ Time: endTime },
  })

The same code works if I remove StartedAt and EndedAt.

Here's the error:

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

goroutine 1 [running]:
github.com/nicklaw5/helix.(*Client).getBaseURL(0x94f500, 0x7061c4, 0x6, 0x6bf460, 0xc000169d90)
        /home/fish/go/pkg/mod/github.com/nicklaw5/helix@v0.5.9/helix.go:307 +0xff
github.com/nicklaw5/helix.(*Client).newRequest(0x94f500, 0x705c51, 0x3, 0x7061c4, 0x6, 0x695bc0, 0xc000102e70, 0x40e100, 0x20, 0x6bf460, ...)
        /home/fish/go/pkg/mod/github.com/nicklaw5/helix@v0.5.9/helix.go:253 +0x46
github.com/nicklaw5/helix.(*Client).sendRequest(0x94f500, 0x705c51, 0x3, 0x7061c4, 0x6, 0x695a80, 0xc0001103a0, 0x695bc0, 0xc000102e70, 0x40e100,
 ...)
        /home/fish/go/pkg/mod/github.com/nicklaw5/helix@v0.5.9/helix.go:158 +0xca
github.com/nicklaw5/helix.(*Client).get(...)
        /home/fish/go/pkg/mod/github.com/nicklaw5/helix@v0.5.9/helix.go:133
github.com/nicklaw5/helix.(*Client).GetUsers(0x94f500, 0xc000102e70, 0x2a, 0xc000169ed8, 0x40e198)
        /home/fish/go/pkg/mod/github.com/nicklaw5/helix@v0.5.9/users.go:42 +0xa0
main.get_user_id_from_username(0x706a7a, 0x8, 0x7083f0, 0xe)
        /home/fish/twitch-discord-bot/main.go:17 +0xa9
main.main()
        /home/fish/twitch-discord-bot/main.go:38 +0x145
exit status 2

I goofed; I'm segfaulting no matter the request so I assume I did something wrong setupwise

Whoops, looks like this is my bad. I'd set up a global twitchClient *helix.Client and using it in bad ways