Skip to content

Instantly share code, notes, and snippets.

@eparis
Last active August 29, 2015 14:19
Show Gist options
  • Save eparis/458542ddda01fa9850f9 to your computer and use it in GitHub Desktop.
Save eparis/458542ddda01fa9850f9 to your computer and use it in GitHub Desktop.
// argsMinusFirstX removes only the first x from args. Otherwise, commands that look like
// openshift admin policy add-role-to-user admin my-user, lose the admin argument (arg[4]).
func argsMinusFirstX(args []string, x string) []string {
for i, y := range args {
if x == y {
return append(args[:i], args[i+1:]...)
}
}
return args
}
(stolen from https://github.com/golang/go/wiki/SliceTricks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment