os, syscall: add Unsetenv
Also address a TODO, making Clearenv pass through to cgo.
Based largely on Minux's earlier https://codereview.appspot.com/82040044
Fixes Issue 6423
Hello rsc@golang.org (cc: golang-codereviews@googlegroups.com, iant@golang.org, r@golang.org), I'd like you to review this change to https://go.googlecode.com/hg/
10 years, 5 months ago
(2014-09-30 21:46:21 UTC)
#1
i don't necessarily consider this change to fall under the syscall lockdown since it's os ...
10 years, 5 months ago
(2014-09-30 22:08:30 UTC)
#6
i don't necessarily consider this change to fall under the syscall lockdown
since it's os that's getting the functionality and we did say that syscall would
always support the main repo. and the functionality is useful in all
environments.
the lockdown is more about stopping new system calls coming in.
discuss.
https://codereview.appspot.com/148370043/diff/70001/src/os/env.go
File src/os/env.go (right):
https://codereview.appspot.com/148370043/diff/70001/src/os/env.go#newcode97
src/os/env.go:97: // UnsetEnv unsets a single environment variable.
what's the point of the error return?
PTAL, now without new package, and comments addressed. On Tue, Sep 30, 2014 at 4:26 ...
10 years, 5 months ago
(2014-10-01 01:04:25 UTC)
#10
PTAL, now without new package, and comments addressed.
On Tue, Sep 30, 2014 at 4:26 PM, <alex.brainman@gmail.com> wrote:
> Windows code looks good. But windows syscall.unsetenv should return
> error to the user.
>
> Alex
>
> https://codereview.appspot.com/148370043/
>
On Tue, Sep 30, 2014 at 7:47 PM, <rsc@golang.org> wrote: > > https://codereview.appspot.com/148370043/diff/110001/src/ > syscall/env_unix.go ...
10 years, 5 months ago
(2014-10-01 02:53:21 UTC)
#19
On Tue, Sep 30, 2014 at 7:47 PM, <rsc@golang.org> wrote:
>
> https://codereview.appspot.com/148370043/diff/110001/src/
> syscall/env_unix.go
> File src/syscall/env_unix.go (right):
>
> https://codereview.appspot.com/148370043/diff/110001/src/
> syscall/env_unix.go#newcode53
> src/syscall/env_unix.go:53: envLock.RLock()
> should be Lock/Unlock not RLock/RUnlock
>
> https://codereview.appspot.com/148370043/diff/110001/src/
> syscall/env_unix.go#newcode58
> src/syscall/env_unix.go:58: envs = append(envs[:i], envs[i+1:]...)
> This seems too expensive (especially the map recreation below).
> Can we do
>
> envs[i] = ""
>
> and drop the copyenv, and then in Environ we have to filter out the
> empty strings when preparing the result, but that's cheap.
>
Done.
Do we care about making sure we filter out all environments with that key
if there are dups?
LGTM with tweak https://codereview.appspot.com/148370043/diff/150001/src/syscall/env_unix.go File src/syscall/env_unix.go (right): https://codereview.appspot.com/148370043/diff/150001/src/syscall/env_unix.go#newcode58 src/syscall/env_unix.go:58: for i, pair := range envs ...
10 years, 5 months ago
(2014-10-01 13:40:06 UTC)
#22
Issue 148370043: code review 148370043: os, syscall: add Unsetenv
(Closed)
Created 10 years, 5 months ago by bradfitz
Modified 10 years, 5 months ago
Reviewers: gobot
Base URL:
Comments: 11