mirror of
https://github.com/golang/go
synced 2024-11-05 15:26:15 -07:00
4f074b58d2
The wrapper takes a pointer to the argument, not the argument itself. Fixes #36705 Change-Id: I566d4457d00bf5b84e4a8315a26516975f0d7e10 Reviewed-on: https://go-review.googlesource.com/c/go/+/215942 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
28 lines
603 B
Go
28 lines
603 B
Go
// +build cgo
|
|
// run
|
|
|
|
// Copyright 2020 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.
|
|
|
|
package main
|
|
|
|
// #include <stdlib.h>
|
|
// #include <unistd.h>
|
|
import "C"
|
|
|
|
import "os"
|
|
|
|
func main() {
|
|
os.Setenv("FOO", "bar")
|
|
s := C.GoString(C.getenv(C.CString("FOO")))
|
|
if s != "bar" {
|
|
panic("bad setenv, environment variable only has value \"" + s + "\"")
|
|
}
|
|
os.Unsetenv("FOO")
|
|
s = C.GoString(C.getenv(C.CString("FOO")))
|
|
if s != "" {
|
|
panic("bad unsetenv, environment variable still has value \"" + s + "\"")
|
|
}
|
|
}
|