v.mod: remove commas; add example for v.vmod (#6169)

pull/6175/head
Lukas Neubert 2020-08-19 16:07:10 +02:00 committed by GitHub
parent 88bca9d17a
commit eabc2daf86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 11 deletions

View File

@ -7,7 +7,6 @@ module main
// structure of the program in the _current_ directory, while `new`
// makes the program structure in a _sub_ directory. Besides that, the
// functionality is essentially the same.
import os
struct Create {
@ -23,11 +22,11 @@ fn cerror(e string) {
fn vmod_content(name, desc string) string {
return [
'Module {',
" name: '$name',",
" description: '$desc',",
" version: '0.0.0',",
" name: '$name'",
" description: '$desc'",
" version: '0.0.0'",
' dependencies: []',
'}'
'}',
].join('\n')
}
@ -36,7 +35,7 @@ fn main_content() string {
'module main\n',
'fn main() {',
" println('Hello World!')",
'}'
'}',
].join('\n')
}
@ -46,7 +45,7 @@ fn gen_gitignore(name string) string {
'$name',
'*.so',
'*.dylib',
'*.dll'
'*.dll',
].join('\n')
}

11
examples/vmod.v 100644
View File

@ -0,0 +1,11 @@
module main
import v.vmod
fn main() {
mod := vmod.decode(@VMOD_FILE) or {
panic('Error decoding v.mod')
}
println('$mod.name has version $mod.version')
println('\nThe full mod struct: \n$mod')
}

9
v.mod
View File

@ -1,7 +1,8 @@
Module {
name: 'V',
description: 'The V programming language.',
version: '0.1.29',
repo_url: 'https://github.com/vlang/v',
name: 'V'
description: 'The V programming language.'
version: '0.1.29'
license: 'MIT'
repo_url: 'https://github.com/vlang/v'
dependencies: []
}