f is analytic except possibly on $|z|=1$ and agrees with entire function $g$ when $|z|=1$, then $f$ is entire. A question from a past qualifying exam at my university reads
"Let $f$ be continuous on $\mathbb{C}$ and analytic except possibly on the unit circle
$\{|z| = 1\}$. Suppose that there is an entire function $g$ such that $f(z) = g(z)$
for $|z| = 1$. Prove that $f = g$ (and hence $f$ is entire)."
If one sets $h(z)=g(z)-f(z)$, then $h$ is identically zero on the unit circle, so using the maximum principle, one can conclude that $h$ is zero on the unit disk. Hence $f$ and $g$ agree on the closed unit disk. I do not know how to proceed from here. I have thought about using Morera's theorem, but to no avail.
 A: You've taken care of the case $|z|<1.$ For $|z|>1,$ I'll use this:
Lemma: Let $A=\{1<|z|<2\}.$ Suppose $h$ is holomorphic on $A$ and continuous on $\overline A.$ If $h(z)=0$ for $|z|=1,$ then $h\equiv 0$ in $A.$
Proof: Note that the map $z\to 2/z$ is a bijection of $\overline A$ to $\overline A$ that is holomorphic on $A.$ Also note that this map interchanges the boundary circles.
Consider now the function $h(z)h(2/z).$ This function is holomorphic on $A,$ continuous on $\overline A,$ and equals $0$ on $\partial A.$ By the maximum modulus theorem, $h(z)h(2/z)=0$ everyhere in $A.$
Suppose $h(z_0)\ne 0$ for some $z_0\in A.$ Then $h(z)\ne 0$ in some $D(z_0,r).$ That implies $h(2/z)=0$ in $D(z_0,r),$ and hence in all of $A$ by the identity principle. But the range of $h(2/z)$ equals the range of $h(z),$ contradiction. So $h=0$ in all of $A,$ proving the lemma.
Back to your problem: Simply let $h=f-g,$ apply the lemma to get $f=g$ in $A,$ and then use the identity principle to see $f=g$ in all of $\{1<|z|<\infty\}.$
A: Here is a tedious proof that does not involve Morera (with a little hand waving because I did not have energy to describe the details).
Let $\gamma_r(t) = r e^{it}$, suppose $|w| \neq r$ and define
$\phi_r(w) = {1 \over 2 \pi i} \int_{\gamma_r} {f(z) \over z-w} dz $.
For a fixed $r\neq 1$, $\phi_r$ is analytic on $|z| \neq r$.
For $|w| < r<1$, we see that $\phi_r(w) = f(w)$.
Pick $w \in B(0,1)$.
Using continuity, we see that  $\lim_{r \uparrow 1} \phi_r(w) = \phi_1(w) = f(w)$.
A similar argument shows that $\lim_{r \downarrow 1} \phi_r(w) = \phi_1(w) = f(w)$.
Since $z \mapsto {f(z) \over z-w}$ is analytic on $|z| >1$, we see that (using a homotopy) that $\phi_{r}(w) = \phi_{r'}(w)$ for $1 < r < r'$.
Hence $\phi_r(w) = f(w)$ for any $r>|w|$.
A similarly tedious argument shows that for $|w|>r$, $\phi_r(w) = 0$.
Now, for arbitrary $w$, choose $r>|w|$ and define $h(w) = \phi_r(w)$. Since
$\phi_{r'}(w) = \phi_r(w)$ for $r' > r$, we see that $h$ is well defined
and analytic on $B(0,r)$ for all $r>0$. Hence $h$ is entire. The above
shows that $h(w) = f(w)$ for $|w|<1$.
All that remains is to show that for $w$ outside the unit disk that
$h(w) = f(w)$ (continuity does the rest).
Choose $r'>|w|>r>1$ and let $\eta(t) = z_0+\delta e^{it}$, with $\delta>0$ small enough so that
$\eta$ does not intersect the $r'$ circle or the $r$ circle.
Note that $S=\{z | | |z|>1, |z-w| >{1 \over 2}\delta, z\neq t w$ for $t\ge 0 \}$ is open and simply connected and $z \mapsto {f(z) \over z-w}$ is analytic on $\{ z | |z|>1, |z-w| >{1 \over 2}\delta \}$.
In particular, for any closed, rectifiable curve $C$ in $S$ we have
$\int_C {f(z) \over z-w} dz = 0$.
Now, with a little hand waving (I'm tired already) we can choose a sequence
of curves $C_n$ in $S$ such that $C_n$ converges appropriately to the
curve in the drawing below and so we get
$\int_{\gamma_{r'}}{f(z) \over z-w} dz -\int_{\eta}{f(z) \over z-w} dz - \int_{\gamma_{r}} {f(z) \over z-w} dz = 0$.
Since $\int_{\gamma_{r}} {f(z) \over z-w} dz = \phi_r(w) = 0$ we have
$h(w) = {1 \over 2 \pi i}\int_{\gamma_{r'}}{f(z) \over z-w} dz  = {1 \over 2 \pi i}\int_{\eta}{f(z) \over z-w} dz = f(w)$.

Since $h=f$ we see that $f$ is entire and since $f=g$ on the unit disk, we have $f=g$.
