TITLE: Isn't this a non-surjective epimorphism on the category of sets?
QUESTION [5 upvotes]: I am trying to prove that a morphism in the category of sets is epic iff it is a surjective function.
Recall that for objects $A,B,C$, $f \in \hom(A,B)$ is epic when $g_1 \circ f = g_2 \circ f \Rightarrow g_1 = g_2, \forall g_1, g_2 \in \hom(B,C)$. 
Consider $A= \{0\}, B= \{1,2\}, C=\{3\}$. Since there is only one element in $\hom(B,C)$, $g_1 \circ f = g_2 \circ f \Rightarrow g_1 = g_2, \forall g_1, g_2 \in \hom(B,C)$ is trivially satisfied $\forall f \in \hom(A,B)$
In particular,
$f : A \rightarrow B $
$f(0) \mapsto 1$
is an epimorphism, but $f$ is non-surjective.
Am I missing something about how categories are defined? Or is it simply false that the original implication is two-sided?

REPLY [2 votes]: For the sake of an answer,
In order for $f$ to be an epimorphism, it has to be right-cancellative for all morphisms $B\to C$ for all objects $C$. 
Take $C=\{3,4\}$. Define $f(0)=1$, as above, which is not surjective. Define $g_1,g_2\in\operatorname{Mor}(B,C)$ by $g_1(1)=3, g_1(2)=3$, and $g_2(1)=3,g_2(2)=4$. Then $g_1\circ f=g_2\circ f$ as both are the constant functions $A\to C$ with image $\{3\}$, but $g_1\neq g_2$. So $f$ is not an epimorphism either.