examples: lang: Fix env0 example

Change function calls to the correct
one, remove extra argument in getenv
call, and fix typo.
This commit is contained in:
Omar Al-Shuha
2024-07-07 23:55:19 +02:00
parent 74f747e80b
commit ccb0e55d5a

View File

@@ -4,20 +4,20 @@
import "fmt" import "fmt"
import "sys" import "sys"
$x = sys.getenv("TEST", "321") $x = sys.getenv("TEST")
print "print1" { print "print1" {
msg => fmt.printf("the value of the environment variable TEST is: %s", $x), msg => fmt.printf("the value of the environment variable TEST is: %s", $x),
} }
$y = sys.getenv("DOESNOTEXIT", "321") $y = sys.defaultenv("DOESNOTEXIT", "321")
print "print2" { print "print2" {
msg => fmt.printf("environment variable DOESNOTEXIT does not exist, defaulting to: %s", $y), msg => fmt.printf("environment variable DOESNOTEXIT does not exist, defaulting to: %s", $y),
} }
$z = sys.getenv("EMPTY", "456") $z = sys.defaultenv("EMPTY", "456")
print "print3" { print "print3" {
msg => fmt.printf("same goes for epmty variables like EMPTY: %s", $z), msg => fmt.printf("same goes for empty variables like EMPTY: %s", $z),
} }