Package management

  1. v [module option] [param]
module options:
  1. install Install a module from VPM.
  2. remove Remove a module that was installed from VPM.
  3. search Search for a module from VPM.
  4. update Update an installed module from VPM.
  5. upgrade Upgrade all the outdated modules.
  6. list List all installed modules.
  7. outdated Show installed modules that need updates.

You can install modules already created by someone else with VPM:

  1. v install [module]

Example:

  1. v install ui

Modules can be installed directly from git or mercurial repositories.

  1. v install [--once] [--git|--hg] [url]

Example:

  1. v install --git https://github.com/vlang/markdown

Sometimes you may want to install the dependencies ONLY if those are not installed:

  1. v install --once [module]

Removing a module with v:

  1. v remove [module]

Example:

  1. v remove ui

Updating an installed module from VPM:

  1. v update [module]

Example:

  1. v update ui

Or you can update all your modules:

  1. v update

To see all the modules you have installed, you can use:

  1. v list

Example:

  1. > v list
  2. Installed modules:
  3. markdown
  4. ui

To see all the modules that need updates:

  1. v outdated

Example:

  1. > v outdated
  2. Modules are up to date.

Publish package

  1. Put a v.mod file inside the toplevel folder of your module (if you created your module with the command v new mymodule or v init you already have a v.mod file).

    1. v new mymodule
    2. Input your project description: My nice module.
    3. Input your project version: (0.0.0) 0.0.1
    4. Input your project license: (MIT)
    5. Initialising ...
    6. Complete!

    Example v.mod:

    1. // ignore
    2. Module {
    3. name: 'mymodule'
    4. description: 'My nice module.'
    5. version: '0.0.1'
    6. license: 'MIT'
    7. dependencies: []
    8. }

    Minimal file structure:

    1. v.mod
    2. mymodule.v

    The name of your module should be used with the module directive at the top of all files in your module. For mymodule.v:

    1. module mymodule
    2. pub fn hello_world() {
    3. println('Hello World!')
    4. }
  2. Create a git repository in the folder with the v.mod file (this is not required if you used v new or v init):

    1. git init
    2. git add .
    3. git commit -m "INIT"
    4. `
  3. Create a public repository on github.com.

  4. Connect your local repository to the remote repository and push the changes.
  5. Add your module to the public V module registry VPM: https://vpm.vlang.io/new

    You will have to login with your Github account to register the module. Warning: Currently it is not possible to edit your entry after submitting. Check your module name and github url twice as this cannot be changed by you later.

  6. The final module name is a combination of your github account and the module name you provided e.g. mygithubname.mymodule.

Optional: tag your V module with vlang and vlang-module on github.com to allow for a better search experience.