Skip to content

Instantly share code, notes, and snippets.

@fritz0705
Last active August 29, 2015 14:10
Show Gist options
  • Save fritz0705/29a976bd4a0797bede1e to your computer and use it in GitHub Desktop.
Save fritz0705/29a976bd4a0797bede1e to your computer and use it in GitHub Desktop.
var (
// Zustand des endlichen Automatens
state int
// Ergebnis™
resistorsPerContainer = 0
containerCount = 0
)
for _, arg := range os.Args {
switch state {
// Startzustand S0
case 0:
switch arg {
case '--help':
PrintHelp()
// break ist in Golang implizit
case "--resistors-per-container":
state = 1
case "--containers":
state = 2
default:
// error handling
}
// Zustand für --resistors-per-container
case 1:
resistorsPerContainer = [...]
state = 0
// Zustand für --containers
case 2:
containerCount = [...]
state = 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment