Package management
v [module option] [param]
module options:
install Install a module from VPM.
remove Remove a module that was installed from VPM.
search Search for a module from VPM.
update Update an installed module from VPM.
upgrade Upgrade all the outdated modules.
list List all installed modules.
outdated Show installed modules that need updates.
You can install modules already created by someone else with VPM:
v install [module]
Example:
v install ui
Modules can be installed directly from git or mercurial repositories.
v install [--once] [--git|--hg] [url]
Example:
v install --git https://github.com/vlang/markdown
Sometimes you may want to install the dependencies ONLY if those are not installed:
v install --once [module]
Removing a module with v:
v remove [module]
Example:
v remove ui
Updating an installed module from VPM:
v update [module]
Example:
v update ui
Or you can update all your modules:
v update
To see all the modules you have installed, you can use:
v list
Example:
> v list
Installed modules:
markdown
ui
To see all the modules that need updates:
v outdated
Example:
> v outdated
Modules are up to date.
Publish package
Put a
v.mod
file inside the toplevel folder of your module (if you created your module with the commandv new mymodule
orv init
you already have a v.mod file).v new mymodule
Input your project description: My nice module.
Input your project version: (0.0.0) 0.0.1
Input your project license: (MIT)
Initialising ...
Complete!
Example
v.mod
:// ignore
Module {
name: 'mymodule'
description: 'My nice module.'
version: '0.0.1'
license: 'MIT'
dependencies: []
}
Minimal file structure:
v.mod
mymodule.v
The name of your module should be used with the
module
directive at the top of all files in your module. Formymodule.v
:module mymodule
pub fn hello_world() {
println('Hello World!')
}
Create a git repository in the folder with the
v.mod
file (this is not required if you usedv new
orv init
):git init
git add .
git commit -m "INIT"
`
Create a public repository on github.com.
- Connect your local repository to the remote repository and push the changes.
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.
- 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.