The only packages I did before were simple one file packages.

I am now learning how to make a package that has a sub package. The main package calls functions in the subpackage. But user is not supposed to be able to call functions directly in the subpackage.

Here is an example below. I need to have the subpackage in *separate* file, so I can't sub package code in the private part of the main package, at least I do not know how to. 

What Am I doing wrong in the following? Under

```
 C:\Users\me\AppData\Roaming\Mathematica\Applications

```

I have

```
Applications/
   mypkg/
      Kernel/
         init.m
      mypkg.m
      sub.m

```

init.m is

```
 Get ["mypkg`mypkg`"]
 Get ["mypkg`sub`"]

```

mypkg.m is

```
BeginPackage["mypkg`"]
main::usage="main[]"
Begin["`Private`"]
main[]:=Module[{},  
  mypkg`sub`foo[1]
]
End[] (* End Private Context *)
EndPackage[]

```

And sub.m is

```
BeginPackage["mypkg`sub`"]
Begin["`Private`"]
  foo[n_]:=Module[{},
     Print["in mypkg`sub`foo[]"];
     n+1
  ]
End[] (* End Private Context *)
EndPackage[]

```

But now in my notebook, I find I am able to call 

```
 mypkg`sub`foo[]          

```

How is this possible? Since `foo` has no `foo::usage` entry to export it to outside and it is in the private context of sub? 

```
<< mypkg`
mypkg`sub`foo[1]

```

![Mathematica graphics](https://i.stack.imgur.com/etNGy.png)

I want only functions in `mypkg.m` to be able to call functions in `sub.m`. What to fix in the above code for this to happen?

I am finding working with packages with multiple files in Mathematica confusing so far, as it is not clear how to separate scope of things.

V12.