1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: support compile time $env('ENV_VAR') (#8456)

This commit is contained in:
Larpon
2021-01-31 18:22:42 +01:00
committed by GitHub
parent 4f4e3e9b61
commit d25825df57
21 changed files with 235 additions and 42 deletions

View File

@@ -3346,6 +3346,21 @@ executable, increasing your binary size, but making it more self contained
and thus easier to distribute. In this case, `f.data()` will cause *no IO*,
and it will always return the same data.
#### $env
```v
module main
fn main() {
compile_time_env := $env('ENV_VAR')
println(compile_time_env)
}
```
V can bring in values at compile time from environment variables.
`$env('ENV_VAR')` can also be used in top-level `#flag` and `#include` statements:
`#flag linux -I $env('JAVA_HOME')/include`.
### Environment specific files
If a file has an environment-specific suffix, it will only be compiled for that environment.