# \`Using\` doesn't work inside custom module

**URL:** https://discourse.julialang.org/t/using-doesnt-work-inside-custom-module/58742
**Category:** General Usage
**Tags:** module
**Created:** [April 7, 2021, 10:19am UTC](https://discourse.julialang.org/t/using-doesnt-work-inside-custom-module/58742 "2021-04-07T10:19:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Sunny](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Sunny](https://discourse.julialang.org/u/Sunny)
#### Post date: [April 7, 2021, 10:19am UTC](https://discourse.julialang.org/t/using-doesnt-work-inside-custom-module/58742/1 "2021-04-07T10:19:16Z")

</div>

I want to export a function from a custom module that uses some package inside itself, but it works in a unexpected way for me

```julia
module A
export f
using StatsBase
f(x) = StatsBase.sample([x,0])
end

using .A
f(1)

Output
UndefVarError: StatsBase not defined

Stacktrace:
 [1] fff(::Int64) at ./In[1]:3
 [2] top-level scope at In[7]:2
 [3] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091

```

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [April 7, 2021, 10:41am UTC](https://discourse.julialang.org/t/using-doesnt-work-inside-custom-module/58742/2 "2021-04-07T10:41:42Z")

</div>

This code is working for me (Julia 1.6). Can you try to copy-paste it in a fresh Julia instance? The stacktrace suggests that you have run something a bit different from the code shown here.

---

<div class="post-metadata">

### Author: ![Sunny](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Sunny](https://discourse.julialang.org/u/Sunny)
#### Post date: [April 7, 2021, 10:52am UTC](https://discourse.julialang.org/t/using-doesnt-work-inside-custom-module/58742/3 "2021-04-07T10:52:00Z")

</div>

Yep, I edited names before posting. After restarting the Julia everything works, I don’t know why, thanks
