Scary!!!
DH is a mailman and he has always told me to stop dead in my tracks, turn sideways facing the dog (so you can side kick it if necessary)- put your dukes (arms) up in a boxing motion - stomp your foot and scream in a deep/firm voice "git" or "go". It's always worked for him on his route, but hopefully I'll never have to find out if it works for me.

Sorry you were caught so off guard- can be very startling.