For $1\le p < \infty$, $q$ conjugate of $p$ and $f\in L^p(E)$ show that;
$$\|f\|_p = \max_{g\in L^q(E)\\\|g\|_q\le 1} \int_E f.g~d\mu$$
My attempt: (Do I need anything to assume about $E$ to be finite?)
using Holder in equality we have
$$\int_E f.g~d\mu \le \|f\|_{L^p(E)} \|g\|_{L^q(E)}$$
$$\|f\|_{L^p(E)} \ge \frac{\int_E f.g~d\mu}{\|g\|_{L^q(E)}}$$
$$\|f\|_{L^p(E)} \ge \max_{g\in L^q(E)\\\|g\|_q\le 1} \int_E f.g~d\mu$$
No need to assume the finiteness of $E$.
You have only proved for one direction $\max\cdots\leq\|f\|_{L^{p}}$.
For the other direction, for $p>1$, plug $g=\text{sgn}(f)|f|^{p-1}/\|f\|_{L^{p}}^{p/q}$.