Skip to content

Instantly share code, notes, and snippets.

@diego-augusto
Last active March 24, 2022 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diego-augusto/a8219dc70b0de413d1372923e5be0fe0 to your computer and use it in GitHub Desktop.
Save diego-augusto/a8219dc70b0de413d1372923e5be0fe0 to your computer and use it in GitHub Desktop.
golang
we, ok := err.(mongo.WriteException)
if ok {
if strings.Contains(we.WriteErrors.Error(), "E11000") {
if strings.HasPrefix(event.Data.Conversation.Protocol, "20220322") {
event.Data.Conversation.Protocol = replaceAtIndex(event.Data.Conversation.Protocol, '3', 8)
fmt.Printf("\nnew protocol: %s", event.Data.Conversation.Protocol)
err := handler(event)
if err != nil {
log.Printf("\nerror save new event message: %s", err.Error())
return
}
_ = message.Ack()
}
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment