Flashcard CLI app in Golang
var clear map[string]func()

To handle OS specific implementations you may consider using Golang tags feature. See it in action:

flashcard_windows.go

// +build windows

package main

import(
    "os"
    "os/exec"
)

func Clear() {
    cmd := exec.Command("cmd", "/c", "cls")
    cmd.Stdout = os.Stdout
    cmd.Run()
}


flashcard_unix.go

// +build linux

package main

import(
    "os"
    "os/exec"
)

func Clear() {
    cmd := exec.Command("clear")
    cmd.Stdout = os.Stdout
    cmd.Run()
}


To build run go build with -tags windows or -tags linux arguments.

Now there is no need call panic(). go build will exit if implementation of Clear function is missing.

See this for more information.