… at your kid & in front of friends?
First: Admit to yourself that you’re an idiot.
Second: Apologize to your child (who may have gone off to hide) & then apologize to any witnesses (who are probably a bit bewildered & embarrassed for you). You may not get the order right, but eventually do the right thing. Maybe after taking a few moments to yourself. Your apology should probably include an explanation that your child did nothing wrong & your unleashing of foul language was about your own issues (which I guarantee will be a true statement).
Third: Wallow in shame & guilty feelings for the next few days. Maybe apologize again (very briefly so as to not recreate the whole episode for your child & anyone else involved).
Fourth: Realize that for some perfectly normal reason, your inner rage monster has awoken. Immediately address any emotional trigger or stressor that may be poking the monster. Recognize that your reaction as not acceptable, no matter how much stress or emotional drama you may be experiencing. Take appropriate action (be it deep breathing, yoga, meditation, prayer, excercise, chocolate, spending time in nature, a new to-do list, watching stand-up comedy, etc., etc.)
Fifth: Write about it on the Internet. In the third person so as to not reveal that you are the type of parent who would ever fall so low. (This step is entirely optional.)