runtime: implement command line arguments in hosted environments

Implement command line arguments for Linux, MacOS and WASI.
This commit is contained in:
Ayke van Laethem
2021-04-16 15:20:20 +02:00
committed by Ron Evans
parent c47cdfa66f
commit 7b761fac78
8 changed files with 102 additions and 18 deletions
+9
View File
@@ -5,10 +5,19 @@ import (
)
func main() {
// Check for environment variables (set by the test runner).
println("ENV1:", os.Getenv("ENV1"))
v, ok := os.LookupEnv("ENV2")
if !ok {
println("ENV2 not found")
}
println("ENV2:", v)
// Check for command line arguments.
// Argument 0 is skipped because it is the program name, which varies by
// test run.
println()
for _, arg := range os.Args[1:] {
println("arg:", arg)
}
}
+3
View File
@@ -1,2 +1,5 @@
ENV1: VALUE1
ENV2: VALUE2
arg: first
arg: second