Basics
| main.v
| beta.v
|
|__ parent
| mod1.v
|
|__ child
| mod2.v
Codes:
main.v
import parent
import parent.child as pc
fn main(){
parent.name_parent()
pc.name_child()
}
mod1.v
module parent
pub fn name_parent(){
println('Parent!!!')
}
mod2.v
module child
pub fn name_child(){
println('child!!!')
}
beta.v
pub fn beta_test(){
println('Beta!!!')
}
Need some insight on the module structure:
Error when I run main.v to access child directory.
*error: unknown function: parent.child.name_child*
How to access beta.v function from main.v ?
As @Immature trader suggested, the solution is to create a file
v.mod
in the root of your module. For example:The initial contents of
v.mod
, for example:Compiling and running works:
You need to set the root directory for the resolution of relative file paths within a V module. That's what the file
v.mod
does. Unfortunately, it's not documented in the chapter about V modules. There's an open issue to add this information to the documentation.