Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidPointer is returned when the provided pointer is invalid. ErrInvalidPointer = errors.New("invalid pointer provided") // ErrMalformedEnvVar is returned when an environment variable is malformed. ErrMalformedEnvVar = errors.New("malformed environment variable") )
Functions ¶
func ArgvToStrings ¶
ArgvToStrings converts a C-style NULL-terminated array of strings to a Go string slice. This function is used to convert OpenVPN plugin arguments passed from C to Go.
Parameters:
- argv: Pointer to a NULL-terminated array of C strings
Returns:
- []string: A slice containing the converted strings, or nil if argv is nil
Types ¶
type List ¶
func NewEnvList ¶
NewEnvList converts a NULL-terminated C string array of environment variables into a Go map.
The function expects environment variables in the standard "KEY=value" format, where:
- Each string in the array should contain exactly one '=' character
- The key (before '=') is trimmed of leading/trailing whitespace
- The value (after '=') is preserved as-is, including any whitespace or additional '=' characters
- Empty strings in the array are silently skipped
Example input:
["PATH=/usr/bin:/bin", "USER=testuser", "HOME=/home/user", NULL]
Returns a map:
{"PATH": "/usr/bin:/bin", "USER": "testuser", "HOME": "/home/user"}
Parameters:
- envVarsChar: A pointer to a NULL-terminated array of C strings, where each string represents an environment variable in KEY=value format
Returns:
- List: A map containing the parsed environment variables
- error: An error if the pointer is nil (ErrInvalidPointer) or if any variable is malformed (ErrMalformedEnvVar)
Errors:
- ErrInvalidPointer: returned when envVarsChar is nil
- ErrMalformedEnvVar: returned when a variable is missing '=' or has an empty key
Note: If duplicate keys are present (after trimming whitespace), the last occurrence wins.
Click to show internal directories.
Click to hide internal directories.