First you need to identify the root cause of the problem. Typically this is simple: "The dog isn't paying attention to you."
Best way to fix this, is to teach it that when it's walking, it has to pay attention to you. There's a youtube channel I've started watching as I was learning ways to teach our Golden lab pup - and his techniques work wonderfully - mostly because he explains things soooooo well.
Beckman Dog Training.
The following video he shows a Golden Retriever that's very distracted, and he explains how to go about getting his attention.
https://www.youtube.com/watch?v=YnOaPw-SlPw
If you search his videos, I recall a video in past about loose lease walking, and teaching your dog to walk beside you. I've applied his techniques to our dog, and she's improved a lot.
The main points I picked up from him:
Walking is more about training than "walking" .. especially as a young pup. Don't take a walk with a physical location or time as your goal. Often you won't get past your front doorstep! ;)
Be patient, take your time.
The interesting thing he explains for your specific problem (as I have interpreted it), is to walk "unpredicatably". That is, if the dog gets too far ahead of you, turn around 180 degrees, and walk the other way. Be firm (but not too hard) on the leash, force him to follow. Once you get going, if they charge ahead again, ... 180 .. walk the other way. Keep doing it ... you'll notice a distinct change in your dog's behaviour VERY fast.
The second part of this he does, is sudden 90 degree turns away from the dog, or into the dog. If the dog is walking beside you, turn towards them and walk "through" them (don't kick or hurt them of course), but "push" through them ... make it awkward/uncomfortable for them.
The goal here is for them to learn to pay attention to you because "wow this guy is crazy, I have to pay attention .. he's all over the place!" ... kind of thing.
No verbal cues needed, no rewards/treats needed .. although after the dog walks alongside you, loose leash for a few strides, giving them a clear reward of "good boy/girl" and such can be a good reinforcement as they start understanding what's expected of them.
Good luck!!