Goursat's theorem and residue theorem understanding It seems to me that Goursat's theorem doesn't align with the residue formula, because with the residue formula we end up with a number different than zero.
Could you help me find what I understood the wrong way?
Goursat's Theorem: Let $D \subset \mathbb{C} $ an open set and $p$ a point inside D. Let $f$ be continuous on $D$, and holomorphic on $D-\{p\}$. Then for every triangle $T \subset D$ with the interior of $T$ also contained in $D,$ $\int_{T} f(z)=0$.
Residue Theorem: Let $D$ a convex open set and $a_i \in D$. Then for every holomorpic function in $D-\{a_1,a_2,...,a_N\}$ and for every closed curve in $D-\{a_1,a_2,...,a_N\}$ $\int_{T} f(z)=2 \pi i\sum_{j=1}^{N} Res(f,a_j) d_{\gamma}(a_j)$,  where $d_{\gamma}(a_j)$ is $1$ if $a_j$ lies in the interior of $\gamma$ and zero otherwise.
 A: Because $f$ is continuous on $D$, $f$ is bounded near $p$ and hence $p$ is a removeable singularity (see here for instance: http://en.wikipedia.org/wiki/Removable_singularity). Because of this, Goursat's theorem and the Residue Theorem give the same result.
A: Your textbooks has a strange way of stating these theorems.
(Cauchy-)Goursat's theorem states:
Let $U$ be an open, simply connected subset of $\mathbb{C}$ and $f$ be a holomorphic on $U$. 
Let $C$ be any simple closed curve in $U$, then $\oint_Cf(z)dz = 0$.
The theorem as stated in the question fails when $p\in \text{int}\ T$. 
In this case $\text{int}\ T$ is no longer a simply connected domain.
So if you've got some domain $U$ on which the function has singular points $a_i$, the subset where the function is holomorphic $U/\{a_i\}$ is no longer simply connected. This means applying Cauchy-Goursat to $U$ will fail in general and there is no reason to expect integrals surrounding the residues to come out as zero.
There is an extension of Cauchy-Goursat for multiply connected domains 
which says something like:
Suppose we have some set $U$ which has a hole punched out of the middle and $f$ holomorphic on $U$. Then the integral of $f$ over any closed curve that surrounds the hole takes the same value as the integral around the boundary of the hole. 
It is from this (among other things) that the residue theorem is derived.
So lets surround each singular point with an epsilon ball $B_\epsilon(a_i)\in U$. 
By the extension of Cauchy Goursat, $\oint_C f(z)dz = \sum_i \oint_{C_i} f(z)dz$ where $i$ counts each ball interior to $C$. Since $f$ is continuous on $U$ and thus on each $B_\epsilon (a_i)$, it has a convergent Taylor series expansion at each $a_i$; ie no negative powers of $z$. Since polynomials are holomorphic, $\oint_{C_i}f(z)dz=0$ for all $i$.
This agrees with Cauchy residue theorem (well, it essentially is CRT) as each point $a_i$ is a removable singularity, so has a residue of $0$.
