// +build linux dragonfly freebsd netbsd openbsd solaris

package common

import (
	"os"
	"os/user"
	"path/filepath"
)

// GetConfigName gets the correct full path of the configuration file.
func GetConfigName(program, filename string) (string, error) {
	u, err := user.Current()
	if err != nil {
		return "", err
	}

	dir := filepath.Join(u.HomeDir, "."+program)
	if !Exists(dir) {
		err := os.MkdirAll(dir, 0700)
		if err != nil {
			return "", err
		}
	}

	return filepath.Join(dir, filename), nil
}

// GetServerConfigName gets the correct full path of the configuration file for servers.
func GetServerConfigName(program, filename string) (string, error) {
	dir := filepath.Join("/etc", program)
	if !Exists(dir) {
		err := os.MkdirAll(dir, 0700)
		if err != nil {
			return "", err
		}
	}

	return filepath.Join(dir, filename), nil
}

// +build linux dragonfly freebsd netbsd openbsd solaris

package common

import (
	"os"
	"os/user"
	"path/filepath"
)

// GetConfigName gets the correct full path of the configuration file.
func GetConfigName(program, filename string) (string, error) {
	u, err := user.Current()
	if err != nil {
		return nil, err
	}

	dir := filepath.Join(u.HomeDir, "."+program)
	if !Exists(dir) {
		err := os.MkdirAll(dir, 0700)
		if err != nil {
			return "", err
		}
	}

	return filepath.Join(dir, filename)
}

// GetServerConfigName gets the correct full path of the configuration file for servers.
func GetServerConfigName(program, filename string) (string, error) {
	dir := filepath.Join("/etc", program)
	if !Exists(dir) {
		err := os.MkdirAll(dir, 0700)
		if err != nil {
			return "", err
		}
	}

	return filepath.Join(dir, filename)
}

--- 
+++ 
@@ -12,7 +12,7 @@
 func GetConfigName(program, filename string) (string, error) {
 	u, err := user.Current()
 	if err != nil {
-		return nil, err
+		return "", err
 	}
 
 	dir := filepath.Join(u.HomeDir, "."+program)
@@ -23,7 +23,7 @@
 		}
 	}
 
-	return filepath.Join(dir, filename)
+	return filepath.Join(dir, filename), nil
 }
 
 // GetServerConfigName gets the correct full path of the configuration file for servers.
@@ -36,5 +36,5 @@
 		}
 	}
 
-	return filepath.Join(dir, filename)
+	return filepath.Join(dir, filename), nil
 }
Build fix for Unix-likes other than macOS.
