Homotopy composition Hatcher exercise
It helps if you first show that inverses of homotopic paths are homotopic, which is relatively easy to do from the definitions. That is, show that if $f_1 \simeq f_2$, then $\bar{f_1} \simeq \bar{f_2}$. Once you have that, start with $f_0 \simeq f_0 \cdot (g_0 \cdot \bar{g_0}) \simeq (f_0 \cdot g_0) \cdot \bar{g_0}$, and notice that there's a nice copy of $f_0 \cdot g_0$ in there.
Translate this to the fundamental groupoid having the homotopy classes of the paths as its elements.
You are asked to show that $\left[f_{0}\right]\left[g_{0}\right]=\left[f_{1}\right]\left[g_{1}\right]\wedge\left[g_{0}\right]=\left[g_{1}\right]$ implies that $\left[f_{0}\right]=\left[f_{1}\right]$, or shorter: $\left[f_{0}\right]\left[g\right]=\left[f_{1}\right]\left[g\right]\Rightarrow\left[f_{0}\right]=\left[f_{1}\right]$.
Then realize that $\left[g\right]$ has an inverse (as any element in a groupoid). That will do. In my view this is indeed a simpler way.