mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
runtime: implement command line arguments in hosted environments
Implement command line arguments for Linux, MacOS and WASI.
This commit is contained in:
committed by
Ron Evans
parent
c47cdfa66f
commit
7b761fac78
Vendored
+9
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+3
@@ -1,2 +1,5 @@
|
||||
ENV1: VALUE1
|
||||
ENV2: VALUE2
|
||||
|
||||
arg: first
|
||||
arg: second
|
||||
|
||||
Reference in New Issue
Block a user