If $g\circ f$ is injective and $f$ is surjective then $g$ is injective Let $f:A\rightarrow B$ and $g:B\rightarrow C$ be functions, prove that if $g\circ f$ is injective and $f$ is surjective then $g$ is injective.

I need advise or correction if something is incorrect with my proof. Thank you beforehand.

We must show that $g$ is injective, i.e for $x,y\in B, g(x)=g(y)\implies x=y$

Let $x,y\in B$ such that $g(x)=g(y)$. Because $f$ is surjective there exists $a,b \in A$ such that $f(a)=x$ and $f(b)=y$

$\implies g(f(a))=g(f(b))$

$\implies g\circ f(a)=g\circ f(b)$

$\implies a=b$ (by injectivity of $g\circ f$)

$\implies f(a)=f(b)$

$\implies x=y$

Would appreciate any correction in proof writing also!
Your proof is correct. I myself would prove it exactly the same. But, I think it's useful to know more than one way, so here is an alternative solution. It's not profoundly different, but I think it's still worth mentioning.

I'm assuming that $A$ is nonempty (and, since there is a map from $A$ to $B$, $B$ is also nonempty). When $A$ is empty there's not much to prove.

The solution uses left and right inverses. A function with non-empty domain is injective iff it has a left inverse, and a function is surjective iff it has a right inverse.

So, we know that $g\circ f$ has a left inverse $h:C \to A$ and $f$ has a right inverse $k: B \to A$. We want to show that $g$ has a left inverse. Just observe that
$$
(f \circ h) \circ g = (f \circ h) \circ g \circ (f \circ k) = f \circ (h \circ g \circ f) \circ k = f \circ \mathrm{id}_A \circ k = f \circ k = \mathrm{id}_B,
$$
so $(f \circ h)$ is a left inverse for $g$. It follows that $g$ is an injection.

PS: this solution is actually worse than your original one, because this one relies on the axiom of choice (it is used when we say that surjectivity is equivalent to having a right inverse). But it is good in the sense that we don't look at particular elements and manipulate maps as "opaque" objects.
I've proved it on my own like this:

Pick two arbitrary elements of $B$, $y_1$ and $y_2$, with $g(y_1)=g(y_2)$. Since $f$ is surjective, $y_1=f(x_1)$ and $y_2=f(x_2)$ for some $x_1,x_2 \in A$. Then $g(f(x_1))=g(f(x_2))$. Since $f \circ g$ is injective, $x_1=x_2$, and so $f(x_1)=f(x_2)$, or $y_1=y_2$. Finally, $g$ is injective.