forked from coder/sshcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.go
46 lines (39 loc) · 996 Bytes
/
settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"os"
"path/filepath"
"runtime"
"golang.org/x/xerrors"
)
const (
vsCodeConfigDirEnv = "VSCODE_CONFIG_DIR"
vsCodeExtensionsDirEnv = "VSCODE_EXTENSIONS_DIR"
)
func configDir() (string, error) {
if env, ok := os.LookupEnv(vsCodeConfigDirEnv); ok {
return os.ExpandEnv(env), nil
}
var path string
switch runtime.GOOS {
case "linux":
path = os.ExpandEnv("$HOME/.config/Code/User/")
case "darwin":
path = os.ExpandEnv("$HOME/Library/Application Support/Code/User/")
default:
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
}
return filepath.Clean(path), nil
}
func extensionsDir() (string, error) {
if env, ok := os.LookupEnv(vsCodeExtensionsDirEnv); ok {
return os.ExpandEnv(env), nil
}
var path string
switch runtime.GOOS {
case "linux", "darwin":
path = os.ExpandEnv("$HOME/.vscode/extensions/")
default:
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
}
return filepath.Clean(path), nil
}