Hitting straight golf shots might actually be simpler than you think. Many golfers focus on so many different technical parts and positions of the swing. However, it's important to remember that the most important part of the golf swing is what the club is doing through impact.
There are really only two main factors that affect the direction the golf ball goes. The first factor is where the clubface is pointed at impact with the ball. This is approximately 75% of the direction the ball goes. The other 25% is where you are swinging the club or the direction of your swing path just after impact. If the clubface is closed or open, the ball will go that way. Learning how to square your clubface through impact will dramatically improve your direction and ability to hit straight golf shots.
Sometimes an incorrect move in the swing or issues with the swing path will make it difficult to square the clubface at impact. So by trying to work on keeping the clubface square at impact, your swing path should also improve. My simple clubface square drill helps you learn how to square the clubface but also will improve your swing path and plane. In order to correctly square the clubface, the path needs to be on more of an inside to square to inside path at the bottom of the swing arc.
Getting other parts of the swing on track will make it easier to get your clubface square through impact. For example, a swing that is too steep at the top of the backswing and on the downswing will make it difficult to rotate the arms correctly and square the clubhead at impact. So having checkpoints for your swing path will lead to a better impact position.
Swinging over the right shoulder at the top of the backswing is a great checkpoint for your swing path. From a good position at the top of the backswing, you'll naturally be able to swing the club on a better downswing path.
Understanding your swing and what actually makes the ball go straight will make it easier to work on it. Good mechanics and technique are important but it's good to prioritize the things you are working on so you can get the best results in the fastest amount of time. Keeping your swing simple also makes golf easier and will allow you to be more consistent.