1// +build !windows
2
3package main
4
5import (
6	"flag"
7	"os"
8	"os/exec"
9	"path/filepath"
10)
11
12func create_sock_flag(name, desc string) *string {
13	return flag.String(name, "unix", desc)
14}
15
16// Full path of the current executable
17func get_executable_filename() string {
18	// try readlink first
19	path, err := os.Readlink("/proc/self/exe")
20	if err == nil {
21		return path
22	}
23	// use argv[0]
24	path = os.Args[0]
25	if !filepath.IsAbs(path) {
26		cwd, _ := os.Getwd()
27		path = filepath.Join(cwd, path)
28	}
29	if file_exists(path) {
30		return path
31	}
32	// Fallback : use "gocode" and assume we are in the PATH...
33	path, err = exec.LookPath("gocode")
34	if err == nil {
35		return path
36	}
37	return ""
38}
39
40// config location
41
42func config_dir() string {
43	return filepath.Join(xdg_home_dir(), "gocode")
44}
45
46func config_file() string {
47	return filepath.Join(xdg_home_dir(), "gocode", "config.json")
48}
49