mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
drop the os_ prefix on the file names in os. os_test.go can stay.
R=rsc DELTA=793 (392 added, 392 deleted, 9 changed) OCL=24777 CL=24804
This commit is contained in:
parent
73dd4a37f9
commit
6017895659
6 changed files with 10 additions and 10 deletions
27
src/lib/os/env.go
Normal file
27
src/lib/os/env.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Environment variables.
|
||||
// Setenv doesn't exist yet: don't have the run-time hooks yet
|
||||
|
||||
package os
|
||||
|
||||
import os "os"
|
||||
|
||||
var (
|
||||
ENOENV = NewError("no such environment variable");
|
||||
)
|
||||
|
||||
func Getenv(s string) (v string, err *Error) {
|
||||
n := len(s);
|
||||
if n == 0 {
|
||||
return "", EINVAL
|
||||
}
|
||||
for i, e := range sys.Envs {
|
||||
if len(e) > n && e[n] == '=' && e[0:n] == s {
|
||||
return e[n+1:len(e)], nil
|
||||
}
|
||||
}
|
||||
return "", ENOENV
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue