Cauchy-Goursat theorem 

I understand the solution to this question via the use of the following corollary

However for $k+1=0$ you get :
$\displaystyle \oint_0^{2\pi}id\theta$
Why am I not able to apply the cauchy-goursat theorem to get that the integral=0?

There's no contradiction, you just proved $z^{-1}$ doesn't have a primitive function on any open set containing $\gamma_1$.
$(z^n)'=nz^{n-1}$ gives you a primitive function of $z^{n-1}$ only for $n\ne0$, so $z^{-1}$ is excluded. You could think of using the principal branch of the complex logarithm, but that's not even continuous on $\gamma_1$.
