Add Liam Neeson to the list of victims of what’s been dubbed “offense archeology” — social-media mobs that comb the past of prominent people searching for a youthful misdeed with which to bring them down.

Only in this case, no one went rummaging through the Irish actor’s distant past. Neeson himself disclosed his 40-year-old “primal” rage at learning a close friend had been raped — and admitted he’d been “ashamed” of his reaction.

What sent the Twitter mobs howling for his head was the fact that Neeson confessed that, after learning the rapist was black, he went “up and down areas with a cosh” — a club — searching for a random black man to kill.

Would he actually have gone through with it? We’ll never know. At any rate, he said his rage faded after walking it off and going to confession.

No matter: The very fact that Neeson had confessed to a racist thought — one he admitted he found abhorrent — was enough to send social media demanding his scalp.

The tale emerged in an interview to promote his new film, “Cold Pursuit,” which is about revenge, when Neeson was asked how he “taps into” such feelings and he recalled the long-ago incident.

He wasn’t telling this story cavalierly, let alone with pride. He was saying that he can understand why people act irrationally, and with bigotry, because it happened to him once.

And he was ashamed by it. He was telling the story because it was wrong — explaining what he draws on to play someone obsessed with vengeance to the exclusion of morality.

Again, the only actual violence was the rape that Neeson says sent him into an overwrought frenzy. Yet the rush to condemn him was so strong as to cancel red-carpet events and a Neeson late-night TV appearance for the movie.

Others ridiculously even call for the actor to be digitally removed from a still-unreleased film. Some celebs who defended him found themselves barraged by accusations of racism.

Finally, Neeson felt obliged to publicly apologize and declare: “I’m not a racist.”

It’s bad enough that the online mob is determined to end people’s careers and reputations over actual misdeeds or “hate speech.” But Neeson is being crucified for acknowledging that he once had a terrible thought — which he quickly regretted.

The outcry suggests he’d have been better off keeping his mouth shut. The sad lesson: Never, ever share your failings and how you learned from them.