For most dogs, good body language is sufficient to deter them from closing within arm's (or kick's) reach.
Really, for most of them, not showing fear, but talking in a calm, friendly but forceful tone has worked very well.
In cases where that seems unlikely to work, a good stick often gets attention. So can picking up a rock (or miming same).
Spray can work, but note wind direction.
Dog whistles could work.
A gun would not be my first choice for most dogs, but would be my first choice for a drug dealer's attack dog.