Prove holomorphic $f$ is constant if given $f'(z)=0$ only on a curve Let $f(z):U\to\mathbb{C}$ be a holomorphic function, where $U=\left\{z\mid 0<|z|<2\right\}.$ It is given that $f'(z)=0$ for very $z\in C= \left\{z\mid |z|=1\right\}.$ Prove that $f$ is a constant function on $U$.

This is a question I had in my Complex Analysis exam. Its solution is pretty easy if you use the Identity Theorem, but I unfortunately forgot that theorem and didn't use it. I would like to know what you think about my solution:
My solution: Let $D=\left\{z\mid 0<|z|<1\right\}$. Since $f$ is holomorphic, then $f'$ is also holomorphic, and then we can use Cauchy's Integral Formula, by which, for every $z\in D$, if we choose to use the curve $C$:
$$f'(z)=\oint_C\frac{f'(w)}{w-z}\ dw=0$$
Therefore, $f'(z)=0$ for every $z\in D$. Let $K$ be a complex constant such that $f(z)\equiv K$ for every $z\in D$, and let $g(z)=f(z)-K$. We know that $g(z)\equiv 0$ for every $z\in D$, thus there exists $z_0\in D$ such that $z_0$ is a zero of $g$ which is not isolated. Since $g$ is holomorphic as a difference of holomorphic functions, $g$ must be equal to the zero function on the entire of $U$, because every holomorphic function which is not constant has only isolated zeroes. Thus $g\equiv 0$ on $U$, meaning $f\equiv K$ on $U$.


*

*The theorem of isolated zeroes is not a theorem that I've studied in the course, so I explained it with power series. 


Thanks! 
P.S.: I'm not sure if using Cauchy's Integral Formula is valid when there might be a singularity inside of the curve which is used. $f$ might not be holomorphic on $0$. If it's not, is it a problem?
 A: Your proof is not valid. Cauchy's integral formula
$$
  g(z)=\frac{1}{2 \pi i}\oint_C\frac{g(w)}{w-z}\ dw
$$
in it's simplest form requires that $g$ is holomorphic in a neighbourhood of the closure of the disk $D$ and $C$ is the (counter-clockwise) circle forming the boundary of $D$. That cannot be applied here because $g = f'$ is not holomorphic at $z=0$. 
There is also a variant
$$
  N(w, \gamma) g(z)=\frac{1}{2 \pi i}\oint_\gamma\frac{g(w)}{w-z}\ dw
$$
where $f$ is holomorphic in $U$, $\gamma$ a cycle which is homologous to zero in $U$, and $N(w, \gamma) $ is the winding number of $w$ with respect to $\gamma$. That cannot be applied here because your $C$ is not  homologous to zero in $U=\left\{z\mid 0<|z|<2\right\}$, since $N(0, C) = 1 \ne 0$.
A: Using Laurent series, we can write
$$f(z)=\sum_{-\infty}^{\infty}a_nz^n$$
for $z\in U.$ It follows that
$$f'(z)=\sum_{n\ne 0}na_nz^{n-1}.$$
On the unit circle, we get
$$f'(e^{it})=\sum_{n\ne 0}na_ne^{int}.$$
Now apply a little Fourier series:
$$\int_0^{2\pi}|f'(e^{it})|^2\,dt = \sum_{n\ne 0}|na_n|^2.$$
It follows that $a_n=0,n\ne 0.$ Therefore $f=a_0$ everywhere, i.e., $f$ is constant.
