Are you asking how to do this in Go or how to do it in general?
Here's how the hk app does it: https://github.com/heroku/hk/blob/master/main.go#L120
Basically it reads the arguments to the executable and matches them against a built-in list of supported commands and dispatches appropriately.