Skip to content

Instantly share code, notes, and snippets.

@cloverstd
Forked from cubarco/simplehttpserver.go
Last active August 19, 2016 08:21
Show Gist options
  • Save cloverstd/a2d7778e667d7cee7c082ae236908109 to your computer and use it in GitHub Desktop.
Save cloverstd/a2d7778e667d7cee7c082ae236908109 to your computer and use it in GitHub Desktop.
1Password Anywhere go
package main
import (
"flag"
"os/user"
"fmt"
"net/http"
go_path "path"
)
func main() {
var port, path string
usr, err := user.Current()
if err != nil {
fmt.Println(err)
return
}
home_dir := usr.HomeDir
one_password_path := go_path.Join(home_dir, "/Dropbox/1Password/1Password.agilekeychain")
flag.StringVar(&port, "port", "8000", "the port of http file server")
flag.StringVar(&path, "path", one_password_path, "the path of Dropbox 1Password path")
flag.Parse()
fmt.Printf("Serving HTTP on 0.0.0.0 port %s ...\n1Password located on %s\n", port, path)
h := http.FileServer(http.Dir(path))
http.ListenAndServe(":"+port, h)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment