It's very similar to CPR for humans, however, this page lists how many compressions per minute you should be doing, etc. It only takes a minute to read and who knows when it might actually come in handy?
Goldfish CPR story time:
I can say that I've never thought about needing to get my cat or dog mouth-to-mouth, but I can say that my mom used to do similar CPR to a fish we had on a regular basis. He was black moor who had an obsession with the blue rocks that were mixed into his tank's gravel. Even though we tried to remove most of the blue rocks and would cover up the bottom with as many large flat rocks, plants, etc, he would still hunt them out every so often.
And when this happened, he would choke. The blue rocks were bigger than the others and would wedge into his little fishy lips, blocking off his airway (well, his, uh, waterway....regardless, couldn't get water through :P). Belly up he'd go, gasping and sputtering. As soon as we'd notice it, my mom would reach in and try to dislodge it with her fingernail, but most times he'd suck it in too far and she'd have to carefully wedge and wiggle it out with a toothpick.
You can imagine how difficult this would be and I can vividly recall her cursing at him as she'd plunge him back in water, hoping he'd get enough water in to keep breathing a bit longer while she worked ever so carefully not to tear his lips with the toothpick. When she'd finally get it, he'd want to just lay in her hand in the water. I couldn't sworn we lost him on numerous occasions, but there she'd be, gently squeezing his sides, forcing the water in and out when he was too weak to do it himself, and sure enough, a while later, he'd be up and swimming like normal.
Until the next time he'd go belly up...