Created
December 29, 2016 14:39
-
-
Save alileza/e80349466464cece131170c66528e01e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"os" | |
"strings" | |
) | |
func main() { | |
args := os.Args[1:] | |
if len(args) == 0 { | |
log.Fatal("argument is needed") | |
} | |
file, err := ioutil.ReadFile(args[0]) | |
if err != nil { | |
log.Fatal(err) | |
} | |
commands := strings.Split(string(file), "\n") | |
for _, command := range commands { | |
cmd := strings.Split(command, " ") | |
switch cmd[0] { | |
case "makan": | |
makan(cmd[1]) | |
case "mandi": | |
mandi(cmd[1], cmd[2]) | |
} | |
} | |
} | |
func makan(args string) { | |
fmt.Println("Makan ", args) | |
} | |
func mandi(kapan, dimana string) { | |
fmt.Println("Mandi ", kapan, " di ", dimana) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment