V for Go programmers — Getting Started

Kevin Da Silva
2 min readApr 10, 2023

Hi everyone, recently I got in touch with a book, called “Introducing Go” and many aspects of Go are very lookalike V, and the approach to Go learning seems like an interesting approach to also learning V, so based on “Introducing Go” I decided to start a new series called Introducing V, in order to share knowledge on V and compare the respective nuances with Go.

v logo

Getting Started

So to get this series started, the first chapter in“Introducing Go” is called “Getting Started”, which shows details about setup and a hello world program:

package main
import "fmt"
// this is a comment
func main() {
fmt.Println("Hello, World")
}

To learn how to install V the documentation has a pretty good explanation here, and for text editors, I recommend vs code with the V extension.

Or alternatively you can use the V playground online.

Hello V:
To do a simple hello world in V we don’t have to declare a function or import modules, we just have to:

module main

println("Hello, World")

The module keyword is equivalent to package in Go that is equivalent to class keyword in a OO language, it works to separate code into modules

We didn’t have to import fmt to be able to do a hello world which is a point for V, but in case we need to import modules we just have to do the following:

module main

import os

println(os.home_dir())
println(os.ls("./") or {[]})
println("Hello, World")

We didn’t needed a function until now, but if we want to declare one we just have to use the following syntax:

module main

import os

fn main() {
println(os.home_dir())
println(os.ls("./") or {[]})
println("Hello, World")
}

for more details on the os module and its functions click here

Comments in V are pretty much the same as in Go, // for one line comments and /* */ for multi-line comments:

// Im one line comment
fn main() {
println(os.home_dir())
println(os.ls("./") or {[]})
/* multi line comment starting here
and here
ooh and here too */
println("Hello, World")
}

The end of each chapter of “Introducing Go” also has some exercises, so I will paste the ones that make more sense at the end of every chapter:

  • Modify the program we wrote so that instead of printing Hello, World it prints Hello, my name is followed by your name

And we covered the first chapter, and got started successfully with V, thank you for reading and soon I will be posting more chapters for this series!

Hope to see you soon, happy easter!

CHAPTER 2 ->

Also I’m actively looking for a new job opportunity, so if you know something that seems to fit my profile I would love to chat more

--

--

Kevin Da Silva

I'm a back-end developer, functional programming lover, fascinated by computer science and languages. From the south part of Brazil to the world