-
Couldn't load subscription status.
- Fork 18.4k
Description
Proposal Details
There are two primary use-cases for the os.Environ function:
- Passing through environment variables to a sub-command or other executable
- Parsing all environment variables into a map
The latter requires going through each string in os.Environ(), usually splitting it on the = sign, and then getting the last part. This is perilous and potentially bug-prone: what if there's an "=" character in the value of the environment variable? Re-joining everything ""? It is not efficient. A widespread need with so many different implementations recommends a library standard function to cut through the noise.
The parsing method in the unix syscall.Getenv could be abstracted to provide a method EnvironMap() map[string]string for the entirety of the envs, and the windows syscall GetEnvironmentStringsW can be similarly parsed. I recommend adding this method in the syscall package, and then exposing it in os as well.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status