Sha256: dfcbab9bdef16462e6c789595e38dae1aebfe87885e009877235ce686859724d

Contents?: true

Size: 484 Bytes

Versions: 16

Compression:

Stored size: 484 Bytes

Contents

package keyring

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

var tildePrefix = string([]rune{'~', filepath.Separator})

// ExpandTilde will expand tilde (~/ or ~\ depending on OS) for the user home directory.
func ExpandTilde(dir string) (string, error) {
	if strings.HasPrefix(dir, tildePrefix) {
		homeDir, err := os.UserHomeDir()
		if err != nil {
			return "", err
		}
		dir = strings.Replace(dir, "~", homeDir, 1)
		debugf("Expanded file dir to %s", dir)
	}
	return dir, nil
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/99designs/keyring/tilde.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/99designs/keyring/tilde.go