V: Instructions from https://vlang.io/docs#modules seem outdated

Created on 23 Jul 2019  路  8Comments  路  Source: vlang/v

V version: 0.1.15
OS: Linux

What did you do?
I'm trying to grasp how modules work - in particular how custom modules work.
https://vlang.io/docs#modules explain to use v -lib <path/to/modules/module_name>.
Up to this point I haven't been able to use v -lib ... successfully.
I always get:

$ v -lib modules/mymodule
Building module mymodule...
V panic: /home/user/Projects/v/vlib/mymodule doesn't exist

... this is no matter how I try to reference mymodule.

What did you expect to see?
A clear way of how I should make my custom modules

What did you see instead?

V panic: /home/user/Projects/v/vlib/mymodule doesn't exist
Bug Documentation

Most helpful comment

If you want to compile an App with custom Modules, this is how it works:

$ ls
app.v
modulea/
moduleb/

$ cat modulea/module.v
module modulea

pub fn hello() {
  print('Hello ')
}

$ cat moduleb/module.v
module moduleb

pub fn world() {
  println('world!')
}

$ cat app.v
module main
import modulea
import moduleb

fn main() {
  modulea.hello()
  moduleb.world()
}

$ v run app.v
============ running app ============
Hello world!

All 8 comments

@Larpon the concept of user modules doesn't exist yet, it's being developed over the next few weeks, this is why it's not in the docs. Only vlib modules at the moment. Once a user module has been defined and implemented it will be added to the docs. Don't worry this is a priority feature.

Ah I see, no problem.

So v -lib ... is for core modules?

@Larpon it did used to work. But it got broken. It will be working again soon though!

If you want to compile an App with custom Modules, this is how it works:

$ ls
app.v
modulea/
moduleb/

$ cat modulea/module.v
module modulea

pub fn hello() {
  print('Hello ')
}

$ cat moduleb/module.v
module moduleb

pub fn world() {
  println('world!')
}

$ cat app.v
module main
import modulea
import moduleb

fn main() {
  modulea.hello()
  moduleb.world()
}

$ v run app.v
============ running app ============
Hello world!

@AtjonTV thanks!

thanks @AtjonTV :) I didn't even realize that still worked. Just keep in mind this might change at any time. When the new system is implemented it will be announced, hopefully soon :)

Thank you @AtjonTV !

It would seem like it has been updated since then. Closing.
(Reopen if you think it's still out-of-date)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cjmxp picture cjmxp  路  3Comments

oleg-kachan picture oleg-kachan  路  3Comments

lobotony picture lobotony  路  3Comments

XVilka picture XVilka  路  3Comments

medvednikov picture medvednikov  路  3Comments