Konubinix' opinionated web of thoughts

Golang Go

Fleeting

golang

Optimizing Memory Management in Go with GOMEMLIMIT

When applying it to the server, GOMEMLIMIT was set at about 80% of the available memory. After setting GOMEMLIMIT, the OOM issues were resolved. Now, the server operates stably even during times of high request volume, providing uninterrupted service to users.

https://hsleep.medium.com/optimizing-memory-management-in-go-with-gomemlimit-da8ed23e2dcb ([2025-10-16 Thu])

go maps

golang maps are references, like pointers or slices

Map types are reference types, like pointers or slices

https://go.dev/blog/maps

golang interface

panic => exit code 2

workspace

it seems like the common knowledge among Go developers is that the file should never be checked in, because:

GitHub’s default gitignore includes the file since Go: Ignore Go workspace file go.work github/gitignore#3884 Official Go repositories set an example by not checking them in; for example, x/tools does not include one, even though it has two modules connected by a directory replace directive Some third party docs or blog posts echo the recommendation to never check them in, like

https://sebastian-holstein.de/post/2021-11-08-go-1.18-features/

https://github.com/golang/go/issues/53502

For large monorepos with multiple modules, it likely makes sense to check in go.work, as it makes the setup easier and often has no downsides

https://github.com/golang/go/issues/53502

We never gave any advice on it, and the community seems to lean on “never check them in”.

https://github.com/golang/go/issues/53502

We could recommend never checking them in, but I think that’s a bad idea: in some particular scenarios it can make perfect sense to check them in, such as monorepos holding multiple modules.

https://github.com/golang/go/issues/53502

I would hate to have to teach people in my team how to create a go.work file just so gopls will work as expected for them, so it seems very reasonable to just push it into VCS. That’s why I was very surprised to see the proposal suggested against doing that.

https://github.com/golang/go/issues/53502

it is possible and perhaps reasonable to check in a go.work file.

https://github.com/golang/go/issues/53502

For what it’s worth I think it would be fine to fix this issue by updating the docs to say that checking in the file is okay in some cases. Right now we are silent, and there’s widespread “common knowledge” that dictates the file should never be checked in. We should at least clarify that that’s not the official recommendation.

https://github.com/golang/go/issues/53502

If GOWORK is set to off, the command will be in a single-module context. If it is empty or not provided, the command will search the current working directory, and then successive parent directories, for a file go.work

https://go.dev/ref/mod#workspaces

Notes pointant ici