Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
aa3dbf29
Commit
aa3dbf29
authored
Nov 18, 2011
by
Lucio De Re
Committed by
Russ Cox
Nov 18, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
syscall: fix env routines for Plan 9
R=golang-dev CC=ality, golang-dev, rsc
https://golang.org/cl/5364063
parent
ab957154
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
src/pkg/syscall/env_plan9.go
src/pkg/syscall/env_plan9.go
+16
-16
No files found.
src/pkg/syscall/env_plan9.go
View file @
aa3dbf29
...
...
@@ -10,40 +10,40 @@ import "errors"
func
Getenv
(
key
string
)
(
value
string
,
found
bool
)
{
if
len
(
key
)
==
0
{
return
""
,
EINVAL
return
""
,
false
}
f
,
e
:=
Open
(
"/env/"
+
key
)
f
,
e
:=
Open
(
"/env/"
+
key
,
O_RDONLY
)
if
e
!=
nil
{
return
""
,
ENOENV
return
""
,
false
}
defer
f
.
Close
(
)
defer
Close
(
f
)
l
,
_
:=
f
.
Seek
(
0
,
2
)
f
.
Seek
(
0
,
0
)
l
,
_
:=
Seek
(
f
,
0
,
2
)
Seek
(
f
,
0
,
0
)
buf
:=
make
([]
byte
,
l
)
n
,
e
:=
f
.
Read
(
buf
)
n
,
e
:=
Read
(
f
,
buf
)
if
e
!=
nil
{
return
""
,
ENOENV
return
""
,
false
}
if
n
>
0
&&
buf
[
n
-
1
]
==
0
{
buf
=
buf
[
:
n
-
1
]
}
return
string
(
buf
),
nil
return
string
(
buf
),
true
}
func
Setenv
(
key
,
value
string
)
error
{
if
len
(
key
)
==
0
{
return
EINVAL
return
errors
.
New
(
"bad arg in system call"
)
}
f
,
e
:=
Create
(
"/env/"
+
key
)
f
,
e
:=
Create
(
"/env/"
+
key
,
O_RDWR
,
0666
)
if
e
!=
nil
{
return
e
}
defer
f
.
Close
(
)
defer
Close
(
f
)
_
,
e
=
f
.
Write
(
[]
byte
(
value
))
_
,
e
=
Write
(
f
,
[]
byte
(
value
))
return
nil
}
...
...
@@ -54,13 +54,13 @@ func Clearenv() {
func
Environ
()
[]
string
{
env
:=
make
([]
string
,
0
,
100
)
f
,
e
:=
Open
(
"/env"
)
f
,
e
:=
Open
(
"/env"
,
O_RDONLY
)
if
e
!=
nil
{
panic
(
e
)
}
defer
f
.
Close
(
)
defer
Close
(
f
)
names
,
e
:=
f
.
Readdirnames
(
-
1
)
names
,
e
:=
readdirnames
(
f
)
if
e
!=
nil
{
panic
(
e
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment