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:
15
doc/docs.md
15
doc/docs.md
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user