diff options
| author | Christine Dodrill <me@christine.website> | 2017-05-20 23:30:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-20 23:30:47 -0700 |
| commit | 55f50910d96b94658b8d9d6bcaa09be5cc90bc05 (patch) | |
| tree | 07112ff8f7d2a67dbb5f99652181d4e205f877cb /vendor/github.com/google/gops/internal | |
| parent | 372573572913bebe24312b72f2c62d74bb8aba54 (diff) | |
| parent | e8f967619e02ebdd6daa5132012ea2382f34ce91 (diff) | |
| download | xesite-55f50910d96b94658b8d9d6bcaa09be5cc90bc05.tar.xz xesite-55f50910d96b94658b8d9d6bcaa09be5cc90bc05.zip | |
Merge pull request #4 from Xe/Xe/feat/server-side-rendering
Use server-side rendering, redo frontend with hack.css
Diffstat (limited to 'vendor/github.com/google/gops/internal')
| -rw-r--r-- | vendor/github.com/google/gops/internal/internal.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/github.com/google/gops/internal/internal.go b/vendor/github.com/google/gops/internal/internal.go new file mode 100644 index 0000000..1382822 --- /dev/null +++ b/vendor/github.com/google/gops/internal/internal.go @@ -0,0 +1,52 @@ +package internal + +import ( + "errors" + "fmt" + "io/ioutil" + "os" + "os/user" + "path/filepath" + "runtime" + "strings" +) + +func ConfigDir() (string, error) { + if runtime.GOOS == "windows" { + return filepath.Join(os.Getenv("APPDATA"), "gops"), nil + } + homeDir := guessUnixHomeDir() + if homeDir == "" { + return "", errors.New("unable to get current user home directory: os/user lookup failed; $HOME is empty") + } + return filepath.Join(homeDir, ".config", "gops"), nil +} + +func guessUnixHomeDir() string { + usr, err := user.Current() + if err == nil { + return usr.HomeDir + } + return os.Getenv("HOME") +} + +func PIDFile(pid int) (string, error) { + gopsdir, err := ConfigDir() + if err != nil { + return "", err + } + return fmt.Sprintf("%s/%d", gopsdir, pid), nil +} + +func GetPort(pid int) (string, error) { + portfile, err := PIDFile(pid) + if err != nil { + return "", err + } + b, err := ioutil.ReadFile(portfile) + if err != nil { + return "", err + } + port := strings.TrimSpace(string(b)) + return port, nil +} |
