[step:Use smoothness of the divisor to identify the local ideal]
Assume first that $x\in D$. Since $D$ is a smooth divisor, after shrinking $U$ there is a holomorphic coordinate chart
\begin{align*}
\varphi:U\to \varphi(U)\subset \mathbb C^n
\end{align*}
with coordinate functions $z_1,\dots,z_n$ such that
\begin{align*}
D\cap U=\{y\in U:z_1(y)=0\}.
\end{align*}
Since $g$ and $z_1$ are local defining equations for the same smooth reduced Cartier divisor, the equality of effective Cartier divisors means that they generate the same invertible ideal sheaf of $D\cap U$ in $\mathcal O_U$. Two generators of the same principal ideal in the local ring differ by a unit. Equivalently, after shrinking $U$ again if necessary, there is a nowhere-vanishing holomorphic function
\begin{align*}
u:U\to \mathbb C
\end{align*}
such that
\begin{align*}
g=uz_1.
\end{align*}
Thus the ideal sheaf generated by $g$ equals the ideal sheaf generated by $z_1$.
We now show that the kernel of restriction $\mathcal O_U\to i_*\mathcal O_{D\cap U}$ is the principal ideal $(z_1)$. If $h\in \mathcal O_U(V)$ for an open set $V\subset U$ and $h|_{V\cap D}=0$, then in the coordinate chart, choose each sufficiently small coordinate polydisc $P\subset V$ so that $(tz_1,z_2,\dots,z_n)\in P$ whenever $(z_1,\dots,z_n)\in P$ and $0\le t\le 1$. The condition $h|_{V\cap D}=0$ gives $h(0,z_2,\dots,z_n)=0$ on $P\cap D$. Let $\mathcal L^1$ denote one-dimensional [Lebesgue measure](/page/Lebesgue%20Measure) on $[0,1]$, and define the function
\begin{align*}
q:P\to \mathbb C
\end{align*}
by
\begin{align*}
q(z_1,\dots,z_n)=\int_0^1 \frac{\partial h}{\partial z_1}(tz_1,z_2,\dots,z_n)\,d\mathcal L^1(t).
\end{align*}
The integrand is holomorphic in $(z_1,\dots,z_n)$ and continuous in $t$ on the compact interval $[0,1]$. On each compact subset of $P$, all coordinate derivatives of the integrand are uniformly bounded for $t\in[0,1]$, so differentiating under the parameter integral is justified by [uniform convergence](/page/Uniform%20Convergence) on compact subsets. Hence $q$ is holomorphic. The one-variable [fundamental theorem of calculus](/theorems/632) along the segment $t\mapsto (tz_1,z_2,\dots,z_n)$ gives
\begin{align*}
h=z_1q
\end{align*}
on $P$. Hence the germ of $h$ at every point of $D\cap U$ lies in the ideal generated by $z_1$, and therefore in the ideal generated by $g$. Away from $D$, the function $g$ is a unit, so the ideal generated by $g$ is all of $\mathcal O_U$. Consequently,
\begin{align*}
\ker(\mathcal O_U\to i_*\mathcal O_{D\cap U})=g\mathcal O_U.
\end{align*}
[/step]