Skip to content

Instantly share code, notes, and snippets.

@kikuchy
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikuchy/2a5a328a8fd35ed0c5e4 to your computer and use it in GitHub Desktop.
Save kikuchy/2a5a328a8fd35ed0c5e4 to your computer and use it in GitHub Desktop.
Ring Zeroが届いたので、Open URI用のサーバをgolangで書いてみた。完全に自分用。Android StudioとChromeをスイッチする。
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