I keep my dog sidekick nearby when dealing with the goats, and I don't allow any goat to take liberties with my person.
Rosie (the English shepherd bitch) watches my back. The goats respect her a LOT. She moves them where I need them to go, and keeps them back when I have work to do -- like filling their grain bucket. My goats are tame, and that means that they want to be pushy. One thing I notice -- not surprising -- is that they respect me a lot because they see that the dog is obeying me. It's not just that they respect the dog and she keeps them off me. It's more like "Hokey Smokes, she can control that DOG and it listens to her. She must have strong juju!"
I can't imagine keeping hoofstock without having a well-trained stockdog at my side all the time -- I've never done it, and I don't want to try.
But the key, aside from selecting an appropriate dog with the genetic ability to work, is well-trained, and that takes time, effort, and handler ability. And a commitment to meeting the dog's needs, whether they are convenient or not.