访问用户环境变量 [英] Access to user environment variable
问题描述
在我的.bashrc文件中:
export DART_SDK = / home / nicolas / dart / dart-sdk
在命令行中,但我看不到从 dart
这个用户变量,我只看到系统变量,但不是我的:
var env = Platform.environment;
env.forEach((k,v)=> print(Key = $ k Value = $ v));
我试过:
- 在Windows上,并且它可以在Mac上运行
- 。
<我的用户变量是否定义不好?我的代码是坏吗?
使用以下代码:
import'dart:io'; //服务器端/仅命令行包。
main(){
Map< String,String> env = Platform.environment;
env.forEach((k,v)=> print(Key = $ k Value = $ v));
}
我能够覆盖Windows和Mac上的环境变量。在Mac上,我不得不添加行到.bash_profile(.bashrc没有在我的Mac上加载)。
John
以下是dart文件的连结: https:// api.dartlang.org/1.13.0/dart-io/Platform-class.html
In my .bashrc file:
export DART_SDK=/home/nicolas/dart/dart-sdk
In command line, it works when I "echo" it. But I cannot see this user variable from dart
with, I just see system variable but not mine:
var env = Platform.environment;
env.forEach((k,v) => print("Key=$k Value=$v"));
I tried:
- on windows and it works
- on mac but doesn't work
Is my user variable is not well defined? Is my code is bad? It's a bug?
Using the following code:
import 'dart:io'; // Server side / command line only package.
main() {
Map<String, String> env = Platform.environment;
env.forEach((k, v) => print("Key=$k Value=$v"));
}
I was able to override environment variables on both Windows and Mac. On Mac I had to add the line to .bash_profile (.bashrc is not loaded on my Mac).
John
Here is the link to dart docs: https://api.dartlang.org/1.13.0/dart-io/Platform-class.html
这篇关于访问用户环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!