Modules and direct sum 
Let $A$ be a ring and $M$ an $A$-module, given $ g\colon M \to A$ a surjective morphism of $A$-module, prove that $ M \cong \ker(g) \oplus A$.

Here's what I tought:
first the following short sequence is exact
$$ 
0 \to \ker(g)\to M\xrightarrow{f} A \to 0
$$
and if I show that splits I got the thesis. I define a morphism of $A$-modules $ f:A \to M$ the following way
$$
f(a) = a\cdot1_M \space\space \forall a \in A
$$
and since $\forall a \in A$ we have
$$
(g\circ f)(a) = g(a\cdot1_M ) = ag(1_M)=a\cdot1_A = a
$$
We have $gf = \operatorname{id}_A$, the sequence splits and $ M \cong \ker(g) \oplus A$.
What I've done is a possible solution? As last question if is right this could hold for every $M,N$ that are $A$-module and every $h\colon M \to N$ with $h$ surjective morphism and with the hypotesis that $N$ is finitely generated by a single element? Thank you very much.
 A: Question: "As last question if is right this could hold for every $M,N$ that are $A$-module and every $h\colon M \to N$ with $h$ surjective morphism and with the hypotesis that $N$ is finitely generated by a single element? Thank you very much."
Answer: The map $f\colon M \to A$ has a (non-unique) section $s: A\to M$:
pick any $m\in M$ with $f(m)=1$ and define $s(a):=am$.  It follows $f \circ s =\operatorname{id}_A$ .
Define $\phi:= s \circ f: M \to M$. It follows $\phi^2 =\phi$ and $M \cong \ker(\phi) \oplus \operatorname{im}(\phi)=\ker(f)\oplus A$.
There are isomorphisms
$$ a\colon M \cong \ker(\phi) \oplus \operatorname{im}(\phi)$$
defined by $a(m):=(m-sf(m), f(m))$ and
$$b\colon \ker(\phi)\oplus \operatorname{im}(\phi) \to M$$
defined by $b(u,v):=u+s(v)$. You may verify thatt $a\circ b=b \circ a=\operatorname{id}$, hence $a$ and $b$ are isomorphisms of $A$-modules.
Note: There is no "identity element" $1_M \in M$. You must choose an element $m\in M$ mapping to $1\in A$ - the element $m$ is in general not unique.
Note: We define an $A$-module $N$ to be "projective" iff for any surjective map of $A$-modules $f\colon M\to N$ there is a section $s\colon N \to M$ with $f \circ s =\operatorname{id}_N$. There are non-projective $A$-modules.
