Given:
\[
\int_0^x g(t)\,dt = x - \int_0^x t g(t)\,dt
\]
Differentiate both sides with respect to \( x \):
\[
g(x) = 1 - xg(x)
\Rightarrow g(x)(1 + x) = 1
\Rightarrow g(x) = \frac{1}{1 + x}
\]
Now consider the differential equation:
\[
\frac{dy}{dx} - y \tan x = 2(x+1) \sec x \cdot g(x)
= 2(x+1) \sec x \cdot \frac{1}{1+x} = 2 \sec x
\]
So the equation becomes:
\[
\frac{dy}{dx} - y \tan x = 2 \sec x
\]
This is a linear differential equation. The integrating factor is:
\[
\text{IF} = e^{\int -\tan x \, dx} = e^{\ln|\cos x|} = \cos x
\]
Multiplying both sides by the integrating factor:
\[
\cos x \cdot \frac{dy}{dx} - y \cos x \tan x = 2
\Rightarrow \frac{d}{dx}(y \cos x) = 2
\]
Integrating both sides:
\[
y \cos x = \int 2\,dx = 2x + C
\]
Apply the initial condition \( y(0) = 0 \):
\[
0 \cdot \cos 0 = 2 \cdot 0 + C \Rightarrow C = 0
\]
Therefore, the solution is:
\[
y \cos x = 2x \Rightarrow y = \frac{2x}{\cos x} = 2x \sec x
\]
Now, compute \( y\left( \frac{\pi}{3} \right) \):
\[
y\left( \frac{\pi}{3} \right) = 2 \cdot \frac{\pi}{3} \cdot \sec\left( \frac{\pi}{3} \right)
= 2 \cdot \frac{\pi}{3} \cdot 2 = \frac{4\pi}{3}
\]