There are many kinds of golf hats, the most common one is the kind suitable for playing tennis, which is similar to the cap of the duck tongue, and the hollowed-out mesh of the top, all three are universal, and other kinds of golf hats have the style of fisherman hat and cowboy hat.
So golf as a whole tends to be casual and you can wear any hat but tennis has to wear a hat that doesn't interfere with strenuous activity.