Skip to content

Instantly share code, notes, and snippets.

@necrogami
Created February 27, 2017 19:13
Show Gist options
  • Select an option

  • Save necrogami/034fec22c78cf4ea10e2bc4fe4f71504 to your computer and use it in GitHub Desktop.

Select an option

Save necrogami/034fec22c78cf4ea10e2bc4fe4f71504 to your computer and use it in GitHub Desktop.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x109d9b1]
goroutine 1 [running]:
github.com/sony/sonyflake.(*Sonyflake).NextID(0x0, 0x0, 0x0, 0x0)
/Users/necrogami/code/gocode/src/github.com/sony/sonyflake/sonyflake.go:89 +0x41
github.com/osamingo/indigo.(*Generator).NextID(0xc42000c480, 0x0, 0x113b5e0, 0x0, 0x0)
/Users/necrogami/code/gocode/src/github.com/osamingo/indigo/indigo.go:43 +0x32
main.init.1()
/Users/necrogami/code/gocode/src/github.com/necrogami/test/main.go:18 +0xcb
main.init()
/Users/necrogami/code/gocode/src/github.com/necrogami/test/main.go:42 +0x58
exit status 2
package main
import (
"log"
"sync"
"time"
"github.com/osamingo/indigo"
)
var g *indigo.Generator
func init() {
g = indigo.New(indigo.Settings{
// 2009-11-10 23:00:00 UTC
StartTime: time.Unix(1257894000, 0),
})
_, err := g.NextID()
if err != nil {
log.Fatalln(err)
}
}
func main() {
wg := sync.WaitGroup{}
wg.Add(100)
for i := 0; i < 100; i++ {
go func() {
defer wg.Done()
id, err := g.NextID()
if err != nil {
log.Fatalln(err)
} else {
log.Println("ID:", id)
}
}()
}
wg.Wait()
}
@mingfang

Copy link
Copy Markdown

I'm also seeing this problem.
Do you have a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment