Solution (source code)

= Solution
{c}

Along the circle, $z=z_0+re^{it}$ and $dz=ire^{it}dt$. Expanding the nonholomorphic integrand gives
$$
|z|^2=|z_0|^2+r^2+r\overline z_0e^{it}+rz_0e^{-it}.
$$
After multiplication by $ire^{it}$, all nonconstant integer-frequency exponentials have zero integral over $[0,2\pi]$. The remaining constant term is $ir^2z_0$. Therefore
$$
\boxed{\int_\gamma |z|^2dz=2\pi i r^2z_0.}
$$
This direct parametrization avoids applying a holomorphic-antiderivative argument to $|z|^2$, which is not holomorphic.