Let be $g\in\mathcal{C}^1((0,\infty))$ and $f:\mathbb{R}^n\setminus\{0\}\to\mathbb{R}^n$ where $f(x):=g(\Vert x\Vert_2)x$.
Show that $f$ has an antiderivative.
By plain luck I found out the following:
Let be $h:\mathbb{R}^n\to\mathbb{R}$ with $h(x):=\Vert x\Vert_2$ and $G:\mathbb{R}\to\mathbb{R}$ with $G(y):=\int\limits_1^yg(t)t~dt$. Then, by chain rule we can conclude $$ D_i(G\circ h)(x)=G'(h(x))D_ih(x)=g(\Vert x\Vert_2)\Vert x\Vert_2\frac{x_i}{\Vert x\Vert_2}=g(\Vert x\Vert_2) x_i\\\implies F:=G\circ h \text{ is an antiderivative of }f. $$
However, this problem was stated in the context of line integrals so I am wondering if there is an appropriate curve and a line integral to derive an antiderivative.
I have already tried the easiest curve i.e. a straight line between some fixed point $a\in\mathbb{R}^n\setminus\{0\}$ and $x$ but then it might be that $0$ lies on this curve. Any attempts to create a curve that circumvents the point $0$ lead to some messy expressions.
Do you have any ideas which curve to use?
You cannot use a line that pass over zero as $f$ is not defined there, however you can use any straight line from $a \mathbf{w}$ to $b \mathbf{w}$, where $0<a<b$ and $\mathbf{w}\in \{\mathbf{v}\in \mathbb{R}^n:\|\mathbf{v}\|_2=1\}$, then a parametrization of the path is $\gamma :[a,b]\to \mathbb{R}^n,\, t\mapsto t\mathbf{w}$. Then
$$ \int_{\gamma }f(\mathbf{x})\cdot \,d \mathbf{x}=\int_{a}^b\langle (f\circ \gamma )(t),\dot \gamma (t) \rangle \,d t=\int_{a}^b g(t)t\,d t=H(b)-H(a)=H(\|b\mathbf{w}\|_2)-H(\|a\mathbf{w}\|_2)$$
where $H$ is any antiderivative of the map $t\mapsto g(t)t$. So a candidate for an antiderivative of $f$ is $F:=H\circ \|\cdot\|_2$, now you only need to check that $\nabla F(\mathbf{x})=f(\mathbf{x})$ for all $\mathbf{x}\neq 0$.∎