File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -6230,28 +6230,28 @@ Another example, is if you want to embed the version/name from v.mod *inside* yo
62306230
62316231` ` ` v ignore
62326232import v.vmod
6233- vm := vmod.decode( @VMOD_FILE ) or { panic(err) }
6234- eprintln(' ${vm.name} ${vm.version}\n ${vm.description}' )
6233+
6234+ vm := vmod.decode( @VMOD_FILE )!
6235+ eprintln(' ${vm.name} ${vm.version}\n${vm.description}' )
62356236` ` `
62366237
62376238A program that prints its own source code (a quine):
62386239` ` ` v
62396240print($embed_file(@FILE).to_string ())
62406241` ` `
62416242
6242- A program that prints the time when it was built:
6243- ` ` ` v
6244- import time
6245-
6246- println(' This program, was compiled at ${time.unix(@BUILD_TIMESTAMP.i64()).format_ss_milli()} .' )
6247- ` ` `
6248-
62496243> [! NOTE]
62506244> you can have arbitrary source code in the file, without problems, since the full file
62516245> will be embedded into the executable, produced by compiling it. Also note that printing
62526246> is done with ` print` and not ` println` , to not add another new line, missing in the
62536247> source code.
62546248
6249+ A program that prints the time when it was built:
6250+ ` ` ` v
6251+ import time
6252+
6253+ println(' This program, was compiled at ${time.unix(@BUILD_TIMESTAMP.i64()).format_ss_milli()} .' )
6254+ ` ` `
62556255
62566256# ## Compile time reflection
62576257
You can’t perform that action at this time.
0 commit comments