Expand/collapse group button

Can't get this to work for collapsing/expanding groups, any help please.

@if:Go GROUPEXPAND=*
Go GROUPCOLLAPSE=*
@if:else
Go GROUPEXPAND=*

Go GROUPEXPAND / GROUPCOLLAPSE are never marked as being "on" or "currently in effect", but they do get enabled or disabled based on whether they are currently possible or not.
You can use @if:enabled ... to test if a command is enabled, rather than if it is "on".
So this works:

@if:enabled Go GROUPEXPAND=*
Go GROUPEXPAND=*
@if:else
Go GROUPCOLLAPSE=*

Note that as well as adding enabled on the first line, the 2nd and 4th lines are swapped. It's saying "if it's possible to expand all groups, then do so, else collapse all groups."