diff options
author | Ayke van Laethem <[email protected]> | 2021-04-16 15:20:20 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-04-21 10:32:09 +0200 |
commit | 7b761fac7805083dd0263ed376b10e106726ef8f (patch) | |
tree | 4a984aeda71f2b902ba14b1d2b6730f9d862187e /testdata | |
parent | c47cdfa66fe38cfad268615e093969bb136bae07 (diff) | |
download | tinygo-7b761fac7805083dd0263ed376b10e106726ef8f.tar.gz tinygo-7b761fac7805083dd0263ed376b10e106726ef8f.zip |
runtime: implement command line arguments in hosted environments
Implement command line arguments for Linux, MacOS and WASI.
Diffstat (limited to 'testdata')
-rw-r--r-- | testdata/env.go | 9 | ||||
-rw-r--r-- | testdata/env.txt | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/testdata/env.go b/testdata/env.go index 74d271946..115da6d3d 100644 --- a/testdata/env.go +++ b/testdata/env.go @@ -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) + } } diff --git a/testdata/env.txt b/testdata/env.txt index 7aadfb7b4..8ba50a7fd 100644 --- a/testdata/env.txt +++ b/testdata/env.txt @@ -1,2 +1,5 @@ ENV1: VALUE1 ENV2: VALUE2 + +arg: first +arg: second |