summaryrefslogtreecommitdiff
path: root/src/pkg/os/env.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-12-15 15:40:16 -0800
committerRobert Griesemer <gri@golang.org>2009-12-15 15:40:16 -0800
commit13ac778ef2f757c7cd636b4336a2bd6c8f403b43 (patch)
tree28b6ebc4aa762e38c45f4b0b69d3aee472ed4c3c /src/pkg/os/env.go
parente4bd81f903362d998f7bfc02095935408aff0bc5 (diff)
downloadgolang-13ac778ef2f757c7cd636b4336a2bd6c8f403b43.tar.gz
1) Change default gofmt default settings for
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 4th set of files. R=rsc CC=golang-dev http://codereview.appspot.com/180049
Diffstat (limited to 'src/pkg/os/env.go')
-rw-r--r--src/pkg/os/env.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/pkg/os/env.go b/src/pkg/os/env.go
index c1713586d..bdd2ac293 100644
--- a/src/pkg/os/env.go
+++ b/src/pkg/os/env.go
@@ -7,7 +7,7 @@
package os
import (
- "once";
+ "once"
)
// ENOENV is the Error indicating that an environment variable does not exist.
@@ -17,12 +17,12 @@ var env map[string]string
func copyenv() {
- env = make(map[string]string);
+ env = make(map[string]string)
for _, s := range Envs {
for j := 0; j < len(s); j++ {
if s[j] == '=' {
- env[s[0:j]] = s[j+1:];
- break;
+ env[s[0:j]] = s[j+1:]
+ break
}
}
}
@@ -31,56 +31,56 @@ func copyenv() {
// Getenverror retrieves the value of the environment variable named by the key.
// It returns the value and an error, if any.
func Getenverror(key string) (value string, err Error) {
- once.Do(copyenv);
+ once.Do(copyenv)
if len(key) == 0 {
return "", EINVAL
}
- v, ok := env[key];
+ v, ok := env[key]
if !ok {
return "", ENOENV
}
- return v, nil;
+ return v, nil
}
// Getenv retrieves the value of the environment variable named by the key.
// It returns the value, which will be empty if the variable is not present.
func Getenv(key string) string {
- v, _ := Getenverror(key);
- return v;
+ v, _ := Getenverror(key)
+ return v
}
// Setenv sets the value of the environment variable named by the key.
// It returns an Error, if any.
func Setenv(key, value string) Error {
- once.Do(copyenv);
+ once.Do(copyenv)
if len(key) == 0 {
return EINVAL
}
- env[key] = value;
- return nil;
+ env[key] = value
+ return nil
}
// Clearenv deletes all environment variables.
func Clearenv() {
- once.Do(copyenv); // prevent copyenv in Getenv/Setenv
- env = make(map[string]string);
+ once.Do(copyenv) // prevent copyenv in Getenv/Setenv
+ env = make(map[string]string)
}
// Environ returns an array of strings representing the environment,
// in the form "key=value".
func Environ() []string {
- once.Do(copyenv);
- a := make([]string, len(env));
- i := 0;
+ once.Do(copyenv)
+ a := make([]string, len(env))
+ i := 0
for k, v := range env {
// check i < len(a) for safety,
// in case env is changing underfoot.
if i < len(a) {
- a[i] = k + "=" + v;
- i++;
+ a[i] = k + "=" + v
+ i++
}
}
- return a[0:i];
+ return a[0:i]
}