You did the right thing, but I'd be sorely tempted to shoot any dog that attacked me in any circumstances.
If you were trespassing on my property and my dog said "get the fxxx off of my land before you get bitten" and then you shot my dog, you may risk getting shot yourself.
And lunyou is a dumbass for running from a dog. No dog will attack you if you act like a man and look intimidating.