Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func ConfigDir() (string, error) {
return configDir, nil
}

if osUserConfigDir := getOSUserConfigDir(); osUserConfigDir != "" {
return osUserConfigDir, nil
}

if runtime.GOOS == "windows" {
return filepath.Join(os.Getenv("APPDATA"), "gops"), nil
}
Expand Down
19 changes: 19 additions & 0 deletions internal/internal_go1_13.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build go1.13

package internal

import (
"os"
)

func getOSUserConfigDir() string {
configDir, err := os.UserConfigDir()
if err != nil {
return ""
}
return configDir
}
11 changes: 11 additions & 0 deletions internal/internal_lt_go1_13.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build !go1.13

package internal

func getOSUserConfigDir() string {
return ""
}