Last active
August 29, 2015 14:23
-
-
Save kikuchy/2a5a328a8fd35ed0c5e4 to your computer and use it in GitHub Desktop.
Ring Zeroが届いたので、Open URI用のサーバをgolangで書いてみた。完全に自分用。Android StudioとChromeをスイッチする。
This file contains 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 ( | |
"net/http" | |
"os/exec" | |
"log" | |
) | |
func execOSAScript(osaScript string) { | |
err := exec.Command("osascript", "-e", osaScript).Start() | |
if err != nil { | |
log.Fatal(err) | |
} | |
} | |
func rightArrowHandler(w http.ResponseWriter, r *http.Request) { | |
execOSAScript("tell application \"android studio\" to activate") | |
} | |
func leftArrowHandler(w http.ResponseWriter, r *http.Request) { | |
execOSAScript("tell application \"google chrome\" to activate") | |
} | |
func main() { | |
http.HandleFunc("/right", rightArrowHandler) | |
http.HandleFunc("/left", leftArrowHandler) | |
http.ListenAndServe(":8080", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment