Questions tagged [vlang]

Questions related to the V programming language, including its syntax and its libraries.

Filter by
Sorted by
Tagged with
0 votes
0 answers
28 views

VLang Language Server for LSP-Zero.nvim

I'm trying to setup the VLS ( V Language Server ) on nvim using LSP-Zero, I just don't know how to setup the server. This is my current configuration: lsp.lua: local lsp_configurations = require('...
tpadev's user avatar
  • 43
0 votes
2 answers
40 views

vlang: error: Option function field must be unwrapped first

I'm using the PICOEV lib and got this error: Option function field must be unwrapped first unsafe { target.cb(event.data.fd, read_events, &pv) } // target is defines as: pub struct Target { pub ...
H.J.'s user avatar
  • 25
0 votes
1 answer
90 views

How can i add methods to a struct in vlang?

I am quite new to the v language and i discovered this feature, however it seems like i am doing something wrong. I have a struct that gathers information in case an error is found somewhere and i'd ...
THE CAT BROKEN's user avatar
0 votes
1 answer
62 views

V simple regex use

The following code compiles and runs in V 0.4.0 049d685 without a problem but seems to give incorrect results. I must be doing something wrong, but what is it? Thanks in advance. import regex fn ...
Nil's user avatar
  • 3
1 vote
1 answer
47 views

How to add a field with a reserved keyword as its name to a structure?

I'm trying to add a field called type to a V structure used for the C interop. It is failing, because type is a keyword too. The original structure in C: typedef struct some_s { int type; } some_t; ...
Ferdinand Prantl's user avatar
0 votes
0 answers
46 views

V Testing gets stuck after starting server

The computer I'm using is: Distributor ID: Pop Description: Pop!_OS 22.04 LTS Release: 22.04 Codename: jammy When I start up the server in tests it gets stuck with this banner: ---- Testing... -------...
Jon49's user avatar
  • 4,464
0 votes
1 answer
147 views

Problem serving local files with vweb (V-lang's default server)

Description of the problem According to V's doc, using vweb, in order to serve static files one just has to add the following line to a server: app.mount_static_folder_at(os.resource_abs_path('dist'), ...
Serge Hulne's user avatar
0 votes
0 answers
182 views

Creating API gateway in Vlang/vweb

I am a new aspiring software developer (currently network engineer/sysadmin) treating Vlang as my first and hopefully main language of choice. I am trying to build an API gateway for pocketbase. This ...
Habiyakare Aimable's user avatar
-2 votes
1 answer
199 views

Is it possible to achieve the "Clean Architecture" using Go or V-lang? [closed]

TLDR; Is the "Clean Architecture" popularized by Robert Martin possible with V or Go? My imagination tells me it is but I want to hear about your opinions or actual experiences. Some ...
jacob's user avatar
  • 17
1 vote
2 answers
750 views

How vlang compile static binary?

i have tried v -b native -prod hello.v but most modules are not supported. // hello.v println('Hello, World!') How vlang compile static binary ? Updated : i found another parameter -freestanding for ...
Vivian K. Scott's user avatar
0 votes
2 answers
311 views

Memory efficient computation of md5sum of a file in vlang

The following code read a file into bytes and computes the md5sum of the bytes array. It works but I would like to find a solution in V that need less RAM. Thanks for your comments ! import os import ...
Fred's user avatar
  • 607
1 vote
1 answer
179 views

How to get a list of system users in vlang?

I am trying to list all the system users, I know that on Linux I could use awk -F: '{ print $1 }' /etc/passwd and on Windows I could use wmic useraccount get name but I was wondering if there was ...
a coder's user avatar
  • 171
1 vote
1 answer
2k views

How to fix a missing Xcursor.h file in Ubuntu?

Recently, I was trying to install V on my Ubuntu system. It seemed to have worked, but when I tried to run a game written in V to test that it was successful. I received an error saying that my system ...
EngineRunner619's user avatar
1 vote
2 answers
324 views

How to generate a random number in vlang?

I want to randomly pick an item in a array.Like javascript code words[Math.floor(Math.random() * words.length)] But I don't know how to generate a number like javascript Math.random() function in ...
Zhihau Shiu's user avatar
0 votes
1 answer
658 views

Vlang - convert int, u32, u64, f32, f64, etc. to array of bytes in LittleEndian format

I have various variables of different numeric datatypes(int,u32,u64,f32,f64, etc) and want to convert them to an array of bytes. For example: a := 120 // int datatype a_bytes = some_function(a) // ...
impopularGuy's user avatar
2 votes
1 answer
312 views

Vlang module calls confusion

Basics | main.v | beta.v | |__ parent | mod1.v | |__ child | mod2.v Codes: main.v import parent import parent.child as pc fn main(){ parent.name_parent() pc.name_child() } mod1.v ...
Immature trader's user avatar
0 votes
2 answers
142 views

How to get list of supported argument in V (command line)

I have installed v using the official doc on my Ubuntu 20.04 LTS. The installation was successful as I can check the version: $ v version V 0.2.4 310969a When I tried to see the supported args using ...
Prakash P's user avatar
  • 3,612
0 votes
1 answer
111 views

Equivalent function to sscanf in Vlang

Title says it all; looking for an equivalent to sscanf in vlang. Go (which Vlang is similar to), has fmt.sscanf; but I don't see anything similar in the Vlang docs. The somewhat closest method I could ...
jparanich's user avatar
  • 8,402
1 vote
1 answer
329 views

How to create library for v lang by c++

I would like to ask how to create a module on c++ for v lang. For example с++ int some_method() { return 6 } v import my_c_module my_c_module.some_method() I will be grateful for any information ...
Peace's user avatar
  • 11
0 votes
1 answer
107 views

VLang `dial_tcp failed`

I am trying to write up a simple multithreaded vlang app to call 'http://www.google.com' and 'http://www.bing.com' 50 times each and count the response size. But I am getting dial_tcp failed for ...
lprakashv's user avatar
  • 1,121
5 votes
1 answer
575 views

How would I go about creating a static library in Vlang?

I'm relatively new to Vlang, and am trying to create a static library to try and test it out. I assume it just involves compiling to C without and then creating the static library from those C files, ...
Albert Bennett's user avatar
0 votes
2 answers
194 views

Parse float from string (v-lang)

How to convert string values like '2 263.32', '592.06' to float numbers (f64) in V-language? UPD: solved in this way: '1 456.93'.replace(' ', '').f32() == (float) 1456.93. Of courcse, this is a ...
taras's user avatar
  • 43
1 vote
1 answer
261 views

Can I install vlang in Mac OS?

V is getting more and more interesting to me, and I'd like to play with it in MacOS. I'm so used to the make/make install paradigm, so naturally after: xcode-select --install git clone https://github....
Dribbler's user avatar
  • 4,383
0 votes
1 answer
232 views

Howto send keystrokes with V-Lang

I want to send keystrokes with V lang to try to create a testing tool. How can I do that? Like send(enter) or something like that
Jorge Cribb's user avatar
3 votes
1 answer
881 views

Convert a string to an array in vlang

I'm learning V, and as far as my attempts go, although a V string is an array of bytes, array methods are not applicable to strings. So I want to convert a string to an array. I have tried searching ...
Phu Nguyen's user avatar
0 votes
1 answer
95 views

How to safely detele a record?

CONTEXT I created an app which handles todos. I want to be able to delete todos based on an id I get from the url import vweb struct App { vweb.Context } [post] ["/todo/:id/delete"] ...
Anwar's user avatar
  • 4,162
0 votes
1 answer
70 views

router raise error for any other route than slash

CONTEXT I have this program in src/index.v import vweb struct App { vweb.Context } ["/"] pub fn (mut app App) home_index() vweb.Result { return app.html("home") } ["...
Anwar's user avatar
  • 4,162
1 vote
1 answer
199 views

Using TinyCC (tcc) to generate a C wrapper for V

I am trying to find some basis I can use to generate wrappers/bindings for C libraries to be used from Vlang and whilst doing so, I remembered that initially, V uses TCC for it's bootstrap compilation....
Ingwie Phoenix's user avatar
0 votes
1 answer
183 views

How to do Upsert in Vlang

Currently, the ORM for V only supports select, update, and insert. I would like to do a more complicated upsert like this: INSERT INTO Settings (Key, Value) VALUES (?0, ?1) ON CONFLICT(Key) DO UPDATE ...
Jon49's user avatar
  • 4,464
1 vote
2 answers
263 views

Vlang cli examples does not work in intuitive way

I have play bit a fun with vlang cli library, for the first touch, i come with playing from the examples directory of the v sources. You can see it in here vlang cli i'm trying to grasp how to get the ...
greenshirt's user avatar
1 vote
2 answers
414 views

a struct must have a `next()` method to be an iterator

I get this error in vlang: a struct must have a next() method to be an iterator struct Items { item []Item } struct Item { name string link string tags []string } pub fn (mut app App) ...
chovy's user avatar
  • 72.5k
1 vote
1 answer
368 views

Unknown function C.sqlite3 and bad parameter or other API misuse

If sqlite3_open_v2 is commentted, it gives an error: unknown function C.sqlite3 which is strange, why should the prototype affect db :=C.sqlite3(0)? But if it is commented then I get a bad parameter ...
user1461607's user avatar
  • 2,436
0 votes
1 answer
67 views

Why .vmodule/ui 's init() function not directory assigning?

I'm new to v. in .vmodule/ui/lable.v fn (mut l Label) init(parent Layout) { ui := parent.get_ui() l.ui = ui } What's differnce with fn (mut l Label) init(parent Layout) { l.ui = parent....
t.hill's user avatar
  • 33
1 vote
2 answers
597 views

Reading all csv lines

I was able to read the first line (which is the deader in my csv file) as" import encoding.csv path:="file.csv" //mut f := os.read_file(path) or {println(err) return} f := ...
Hasan A Yousef's user avatar
0 votes
1 answer
176 views

is there any way to get terminal width in v?

is There any way to get terminal width in V language? I want to get terminal size (or just columns). this is my code: fn get_terminal_width() int { // help me } fn main() { width := ...
user avatar
3 votes
3 answers
1k views

V-lang: How to send +2500 HTTP requests per second?

I am planning to write my scraper with V and i need to send estimatedly ~2500 request per second but can't figure out what am i doing wrong, it should be sending concurrently but it is deadly slow ...
Yagiz Degirmenci's user avatar
1 vote
1 answer
455 views

ANTLR: not match if a certain character follows

Following code is completely valid in the V programming language: fn main() { a := 1. b := .1 println("$a $b") for i in 0..10 { println(i) } } I want to ...
Thomas S.'s user avatar
  • 5,830
6 votes
1 answer
1k views

V - when memory gets freed

V does have neither a manual memory release, nor a garbage collector (reference counting) nor an owner-based mechanism like Rust. How does it decide when to free memory?
Thomas S.'s user avatar
  • 5,830
3 votes
2 answers
483 views

V: iterate the characters (runes) of a string

According to my understanding, a string in V is wrapped around a byte array encoded as UTF-8. That way, iterating over all string elements returns the bytes: fn main() { s := 'a string with äöü (...
Thomas S.'s user avatar
  • 5,830
2 votes
2 answers
290 views

Does the V language allow to extend base types?

In V language methods are defined separately from the data structures. Does the V language allow to define methods on base types, like Array? Is it possible to write my_method method like fn (array ...
Alex Craft's user avatar
  • 13.7k
2 votes
2 answers
127 views

Can there be more than one struct member per line?

Can I have more than one struct member per line? I was making a struct. It seems like V enforces only one member per line. I don't recall seeing that mentioned anywhere. trial.v:191:2: error: ...
aMike's user avatar
  • 852
0 votes
2 answers
67 views

Bad parse with interpolated strings separated by a dot?

I went to print a version number like v3.14 and got this: version.v:218:30: error: unexpected `$2`, expecting `name` 216 | ver1 := (x >> 24) & 0xFF 217 | ver2 := (x >> 16)...
aMike's user avatar
  • 852
0 votes
0 answers
85 views

Can the path to V have spaces in it?

Can the path to V have spaces in it? I tried to run v fmt and got this: $ v fmt something.v sh: /Users/abcd/Library/Application: No such file or directory Encountered a total of: 1 errors. V ...
aMike's user avatar
  • 852
0 votes
1 answer
431 views

How can I read a binary file in sections?

How can I read a binary file in sections? (read some, skip forward, read some more, ...) I tried the fn (f &File) read_bytes(size int) function, but was surprised that it always reads from the ...
aMike's user avatar
  • 852
1 vote
1 answer
155 views

How can I call the C routine 'lseek'?

How can I call the C routines lseek or ftell or fseek? I tried this (macos 10.12.6): import os #flag -lsystem #include <unistd.h> seeker.v:150:11: error: unknown function: C.lseek 148 | // ...
aMike's user avatar
  • 852
3 votes
1 answer
2k views

How to use C libraries in Vlang for basic statistics

I want to do basic statistics with Vlang. Can I use C libraries? For example, Apophenia: http://apophenia.info/ Or IMSL C stat library: https://docs.roguewave.com/en/imsl/c/8.6/pdf/C_Stat_library....
rnso's user avatar
  • 23.8k
1 vote
2 answers
632 views

Verious Database Connectivity in Vlang with ORM?

Is there any hack || way in V-language default ORM to support MongoDB? Currently, I'm able to connect PostgreSQL as it supports it as a default DB. This is just the RDBMS part, But what if we want to ...
Mayur's user avatar
  • 4,405
3 votes
1 answer
205 views

2D array using loops, bizarre output?

This is a very basic question, but I can't figure out what is happening. I expect nested for loops in V to work like in C and other languages. Using the following for loops to build a 2D array A, I ...
AboAmmar's user avatar
  • 5,449
1 vote
1 answer
352 views

How to write a generic sample function in V?

I would like to implement a generic sample function for arrays in V. The inspiration for this is base::sample() in R. A very basic prototype without the replace and prob options of the R function and ...
nevrome's user avatar
  • 1,481
11 votes
5 answers
2k views

Command line parsing lib VLang

I want to write a command line application with the V programming language. Is there a library for command line parsing?
thinwybk's user avatar
  • 4,193