The converse problem about duality of $L^p$

$\newcommand\ds\displaystyle$

Since continuous functions with compact support are dense in $L^q(\Omega)$, the inequality $$\label{1}\tag{1} \bigg|\int_\Omega fg\bigg|\leq M\,\|g\|_q$$ holds for all $g\in L^q$ (proof at the end).

Suppose that $\int_\Omega|f|^p=\infty$. Let $$ X_n=\{|f|\leq n\},\qquad n\in\mathbb N. $$ Then $\Omega=\bigcup_nX_n$. Write $f(x)=|f(x)|\,e^{i\theta(x)}$. Define $$ g_n=\frac{e^{-i\theta}\,|f|^{p-1}\,1_{X_n}}{\bigg(\ds\int_{X_n}|f|^p\Bigg)^{1/q}}. $$ Then $$ \|g_n\|_q^q=\frac{\ds\int_{X_n}|f|^{q(p-1)}}{\ds\int_{X_n}|f|^p }=1. $$ And $$ \int_\Omega f\,g_n=\frac{\ds\int_{X_n}|f|^p}{\bigg(\ds\int_{X_n}|f|^p\Bigg)^{1/q}}=\bigg(\ds\int_{X_n}|f|^p\Bigg)^{1-1/q}=\bigg(\ds\int_{X_n}|f|^p\Bigg)^{1/p}\xrightarrow[n\to\infty]{}\bigg(\int_\Omega|f|^p\Bigg)^{1/p}=\infty, $$ contradicting your inequality. So $f\in L^p$.


Proof of \eqref{1}. Given $g\in L^q(\Omega)$ there exists a sequence $\{h_n\}$ such that $\|g-h_n\|_q\to0$ (proofs here and here). Then there exists a subsquence, that we still name $\{h_n\}$ that converges pointwise almost everywhere. Then using Fatou's Lemma, $$ \bigg|\int_\Omega fg\bigg|=\bigg|\int_\Omega \lim_nfh_n\bigg|\leq\liminf_n\bigg|\int_\Omega fh_n\bigg|\leq\liminf_n M\|h_n\|_q=M\|g\|_q. $$ The last equality is due to $\big|\|g\|_q-\|h_n\|_q\big|\leq\|g-h_n\|_q$ by the reverse triangle inequality.