On this page
This walkthrough starts with one file, promotes it to a module, adds a test, and produces release artifacts.
Run one file#
Create hello.vo:
func greet(name string) string {
return "Hello, " + name + "!"
}
func main() {
println(greet("Volang"))
}
Check, format, and run it:
vo check hello.vo
vo fmt hello.vo
vo run hello.vo
The default run mode is the bytecode VM. For a longer native workload, use:
vo run hello.vo --mode=jit
Create a module project#
Create an empty directory and initialize its identity:
mkdir hello-app
cd hello-app
vo init example.com/acme/hello-app
vo init writes vo.mod; source remains under your control. Create the source
directories and put reusable logic in greet/greet.vo:
mkdir -p greet tests
package greet
func Message(name string) string {
return "Hello, " + name + "!"
}
Add main.vo:
package main
import "example.com/acme/hello-app/greet"
func main() {
println(greet.Message("module"))
}
Run the project directory:
vo check .
vo run .
Add a test#
Create tests/greeting.vo:
package main
import "example.com/acme/hello-app/greet"
func assert(condition bool, message string) {
if !condition {
panic(message)
}
}
func main() {
assert(greet.Message("Ada") == "Hello, Ada!", "greeting")
}
Run the project tests in the VM and JIT:
vo test --mode=vm
vo test --mode=jit
Build Native AOT#
vo build produces a host executable by default:
vo build . -o hello-app
./hello-app
Use --kind=object for a relocatable object or --target=TRIPLE for a
supported cross target. A custom runtime archive may be supplied with
--runtime=PATH.
Build Web bytecode#
Create a verified bytecode module for the Wasm VM with:
vo build . --kind=bytecode --target=wasm32-unknown-unknown -o hello-app.vob
The vo-web Wasm VM loads the verified bytecode and provides output, memory,
scheduling, and supported platform services.
For browser applications, vo ui build assembles the bytecode, runtime, host adapter,
assets, manifest, and deployment policy into one directory.
Continue#
Read the language tour for syntax, the modules guide before adding external dependencies, and the execution guide before selecting production backends.