Weekend or 2 days is good for Gokarna. If you wish to cover the hidden gem beaches like god's own beach, small hell beach, nirvana beach and heaven beach you need to trek a lot. that's pretty much the only way to see them. But you can cover the usual spots namely paradise beach, om beach, kudle beach, Gokarna beach leisurely in 2 days.
Two days are enough for gokarna if you are planning to just visit and see places like the temple and beaches etc. If you want to add surfing or scuba lessons then it'll require a longer duration. I'm not sure how many days that takes.