No, do not try to use mlock to avoid swapping, except in very specific scenarios. That way lies madness.
To be more explicit about my advice: disable swap and ensure you have sufficient memory for your workload.
Your 14 MB Go binary is not the source of your memory pressure. Your memory pressure is coming from the allocated anonymous pages supporting your programs data structures on the heap.
Have sufficient memory for your workload, monitor it, and let the Go GC and kernel manage memory normally. This will work exactly as you'd hope.
To be more explicit about my advice: disable swap and ensure you have sufficient memory for your workload.
Your 14 MB Go binary is not the source of your memory pressure. Your memory pressure is coming from the allocated anonymous pages supporting your programs data structures on the heap.
Have sufficient memory for your workload, monitor it, and let the Go GC and kernel manage memory normally. This will work exactly as you'd hope.