Skip to content

Conversation

@tatzyr
Copy link
Contributor

@tatzyr tatzyr commented Nov 5, 2025

Closes #73

Changes

  • Add goos.environ() function that returns all environment variables as a Lua table
  • Add tests and documentation

Usage

local goos = require("goos")
local env = goos.environ()
print(env.PATH)
print(env.HOME)

-- Iterate all
for key, value in pairs(env) do
    print(key .. "=" .. value)
end

Copy link
Owner

@vadv vadv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for corner cases like this:
export ENV_VAR=TEST=1

@tatzyr
Copy link
Contributor Author

tatzyr commented Nov 6, 2025

Thanks for the review. Added just 2 corner cases.

Skipped tests for special or non-ASCII env vars since os.Environ() handles them correctly.

Used os.Setenv + defer instead of t.Setenv() due to Go 1.16 in ci.yaml.

@vadv vadv merged commit b3f5fed into vadv:master Nov 6, 2025
6 checks passed
@vadv
Copy link
Owner

vadv commented Nov 6, 2025

https://github.com/vadv/gopher-lua-libs/releases/tag/v0.8.0

thank you @tatzyr !

@tatzyr tatzyr deleted the goos-environ branch November 6, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add function to get all environment variables

2 participants