Skip to content

Instantly share code, notes, and snippets.

@waynr
Last active June 11, 2020 17:48
Show Gist options
  • Save waynr/a53b3f4ab3a80f76bea99c5ae705803d to your computer and use it in GitHub Desktop.
Save waynr/a53b3f4ab3a80f76bea99c5ae705803d to your computer and use it in GitHub Desktop.
group gotools {
perm {
admin {
uid = UID;
gid = UID;
}
task {
uid = UID;
gid = UID;
}
}
cpu {
cpu.shares = 256;
}
memory {
# limit to 6GB
memory.limit_in_bytes = 6442450944;
}
}
~
#!/bin/bash
cgexec \
-g memory,cpu:gotools \
$GOPATH/bin/gopls.real "$@"
$ sudo apt install cgroup-tools
$ mv cgconfig.conf /etc/cgconfig.conf
$ sed -i -e 's|UID|$(id -u)|' /etc/cgconfig.conf
$ sudo cgconfigparser -l /etc/cgconfig.conf
$ mv $GOPATH/bin/gopls $GOPATH/bin/gopls.real
$ ln -sf /path/to/gopls.bash $GOPATH/bin/gopls
@waynr
Copy link
Author

waynr commented May 15, 2020

Also worth noting, to get the most mileage out of this you will probably have to configure your editor to pass the --remote=auto option to gopls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment