https://github.com/hellodword/go-magic
https://github.com/hellodword/go-magic
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hellodword/go-magic
- Owner: hellodword
- Created: 2024-04-22T06:52:47.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T12:47:31.000Z (about 2 years ago)
- Last Synced: 2025-09-12T02:57:28.438Z (10 months ago)
- Language: Shell
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-magic
## environment variables such as GODEBUG
- https://go.dev/doc/godebug [^1]
Go and its packages provide a mechanism called GODEBUG (or else) to reduce the impact such changes have on Go developers using newer toolchains to compile old code, but some of them are not documented, for example the `GODEBUG=quiclogpackets=1` for `golang.org/x/net/quic`: https://github.com/golang/net/blob/f95a3b3a48597cebf9849b84a02cd240fb185b16/quic/log.go#L19
I will try to use Github API and regex to find all of them.
- https://github.com/search?q=org%3Agolang+%2F%28%3F-i%29os%5C.Getenv%5C%28%5B%22%60%5D%5BA-Za-z_%5Cd%5D%2B%5B%22%60%5D%5C%29%2F+language%3AGo+NOT+path%3Atest+&type=code
The GitHub search only returs the first 100 results[^2] [^3], so I think I should clone and search them locally.
```go
// https://github.com/golang/go/blob/7f76c00fc5678fa782708ba8fece63750cb89d03/src/runtime/runtime1.go#L404C13-L404C32
gogetenv("GODEBUG")
os.Getenv("GODEBUG")
os.Setenv("GODEBUG", "")
// https://github.com/golang/go/blob/7f76c00fc5678fa782708ba8fece63750cb89d03/src/os/exec/exec.go#L406
// https://github.com/golang/go/blob/7f76c00fc5678fa782708ba8fece63750cb89d03/src/internal/godebugs/table.go#L19-L59
GODEBUG=
envOr("GOMODCACHE", "")
EnvVar{Name: "CGO_ENABLED"
// https://github.com/golang/go/blob/7f76c00fc5678fa782708ba8fece63750cb89d03/src/runtime/testdata/testprogcgo/catchpanic.go#L43
LookupEnv("CGOCATCHPANIC_EARLY_HANDLER"
```
[^1]: https://github.com/golang/go/blob/7f76c00fc5678fa782708ba8fece63750cb89d03/doc/godebug.md
[^2]: https://github.com/orgs/community/discussions/55202
[^3]: https://github.com/orgs/community/discussions/79052