These functions are triangular, and they all disappear outside of $[0,1]$, so I can compute $\int_0^1 g_n(x) \, dx = 1$ for every $n$. For every $x$, $\lim_{n \rightarrow \infty} g_n(x) = 0$.

So the limit and the integration can't be interchanged.

Here is an animated picture of the functions:

The function $g_n(x)$ becomes a sharp peak at $x=0$ for $n \rightarrow \infty$
and, geometrically, it certainly does not disappear or becomes zero. Instead, it seems
that we get, in the end, what physicists know as a delta function. Informally:
$$
\delta(x) = \begin{cases}
0 & \text{for } x \ne 0 \\
\infty & \text{for } x = 0
\end{cases} \qquad ; \qquad
\int_{-\infty}^{+\infty} \delta(x) \, dx = 1
$$
Whatever definition might be the "rigorous" one, a
delta function,
roughly speaking, is just a very large peak near $x = 0$ with area normed to $1$.
Furthermore, it is typical that the following
function, triangular
as well, is indeed supposed to converge to the delta function - instead of becoming zero -
for $n \rightarrow \infty$ and nobody has any doubt about it.
$$
D_n(x) = \begin{cases}
n^2x + n & \text{if } -1/n \le x \le 0 \\
n - n^2x & \text{if } 0 \le x \le +1/n \\
0 & \text{everywhere else} \end{cases}
$$
The only thing that distinguishes $g_n(x)$ from $D_n(x)$ is that the maximum of
the former is shifted an infinitesimal distance $\lim_{n \rightarrow \infty}
1/(2n)$ with respect to the maximum of the latter at $x=0$.

So it's easy to
see that these functions become one and the same for $n \rightarrow \infty$:
$$
\lim_{n \rightarrow \infty} g_n(x) =
\lim_{n \rightarrow \infty} D_n(x) = \delta(x)
$$
Therefore, in the end, we have two arguments that, unfortunately, also
lead to different outcomes for the iterated limit.

- According to standard mathematics, the iterated limits do not commute: $$\int_0^1 \left[ \lim_{n \rightarrow \infty} g_n(x) \right] \, dx = 0 \qquad \text{and} \qquad \lim_{n \rightarrow \infty} \left[ \int_0^1 g_n(x) \, dx \right] = 1 $$
- According to this physicist, the iterated limits do commute: $$\int_0^1 \left[ \lim_{n \rightarrow \infty} g_n(x) \right] \, dx = 1 \qquad \text{and} \qquad \lim_{n \rightarrow \infty} \left[ \int_0^1 g_n(x) \, dx \right] = 1 $$