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` // structure of the program in the _current_ directory, while `new`
// makes the program structure in a _sub_ directory. Besides that, the // makes the program structure in a _sub_ directory. Besides that, the
// functionality is essentially the same. // functionality is essentially the same.
import os import os
struct Create { struct Create {
@ -23,11 +22,11 @@ fn cerror(e string) {
fn vmod_content(name, desc string) string { fn vmod_content(name, desc string) string {
return [ return [
'Module {', 'Module {',
" name: '$name',", " name: '$name'",
" description: '$desc',", " description: '$desc'",
" version: '0.0.0',", " version: '0.0.0'",
' dependencies: []', ' dependencies: []',
'}' '}',
].join('\n') ].join('\n')
} }
@ -36,7 +35,7 @@ fn main_content() string {
'module main\n', 'module main\n',
'fn main() {', 'fn main() {',
" println('Hello World!')", " println('Hello World!')",
'}' '}',
].join('\n') ].join('\n')
} }
@ -46,7 +45,7 @@ fn gen_gitignore(name string) string {
'$name', '$name',
'*.so', '*.so',
'*.dylib', '*.dylib',
'*.dll' '*.dll',
].join('\n') ].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 { Module {
name: 'V', name: 'V'
description: 'The V programming language.', description: 'The V programming language.'
version: '0.1.29', version: '0.1.29'
repo_url: 'https://github.com/vlang/v', license: 'MIT'
repo_url: 'https://github.com/vlang/v'
dependencies: [] dependencies: []
} }