How do I resolve "cannot import module "greeter" (not found)" #21979
-
Hi, I am receiving the following error when I run v run main.v: cannot import module "greeter" (not found) #I am following along with the documentation, and I have the following two files: src/
main.v:
greeter.v:
Can somebody please help me understand where I'm going wrong? Even if I put the module into a modules folder, and then import it, I still get the same error. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You also need a In other words, set things up like this for them to work:
main.v module main
import greeter
fn main() {
greeter.greet('Jason')
} greeter.v module greeter
pub fn greet(name string) {
println(name)
} output is as expected
|
Beta Was this translation helpful? Give feedback.
Last tip... the
src
subdir isn't required... some like to use it, some don't. The code works exactly the same if you have