// Copyright 2012 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 runtimeimportfunc gogetenv( string) string { := environ()if == nil {throw("getenv before env init") }for , := range {iflen() > len() && [len()] == '=' && envKeyEqual([:len()], ) {return [len()+1:] } }return""}// envKeyEqual reports whether a == b, with ASCII-only case insensitivity// on Windows. The two strings must have the same length.func envKeyEqual(, string) bool {ifGOOS == "windows" { // case insensitivefor := 0; < len(); ++ { , := [], []if == || lowerASCII() == lowerASCII() {continue }returnfalse }returntrue }return == }func lowerASCII( byte) byte {if'A' <= && <= 'Z' {return + ('a' - 'A') }return}// _cgo_setenv should be an internal detail,// but widely used packages access it using linkname.// Notable members of the hall of shame include:// - github.com/ebitengine/purego//// Do not remove or change the type signature.// See go.dev/issue/67401.////go:linkname _cgo_setenvvar _cgo_setenv unsafe.Pointer// pointer to C function// _cgo_unsetenv should be an internal detail,// but widely used packages access it using linkname.// Notable members of the hall of shame include:// - github.com/ebitengine/purego//// Do not remove or change the type signature.// See go.dev/issue/67401.////go:linkname _cgo_unsetenvvar _cgo_unsetenv unsafe.Pointer// pointer to C function// Update the C environment if cgo is loaded.func setenv_c( string, string) {if_cgo_setenv == nil {return } := [2]unsafe.Pointer{cstring(), cstring()}asmcgocall(_cgo_setenv, unsafe.Pointer(&))}// Update the C environment if cgo is loaded.func unsetenv_c( string) {if_cgo_unsetenv == nil {return } := [1]unsafe.Pointer{cstring()}asmcgocall(_cgo_unsetenv, unsafe.Pointer(&))}func cstring( string) unsafe.Pointer { := make([]byte, len()+1)copy(, )returnunsafe.Pointer(&[0])}
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.