mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 03:38:03 +01:00
Don't rely on user.Current - it fails on cross compiled binaries
This commit is contained in:
14
util/cfg.go
14
util/cfg.go
@@ -1,10 +1,12 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"code.google.com/p/gcfg"
|
||||
)
|
||||
@@ -30,10 +32,14 @@ type ConfigLoader interface {
|
||||
type FileConfigLoader struct{}
|
||||
|
||||
func (l *FileConfigLoader) LoadConfig() (*Config, error) {
|
||||
usr, _ := user.Current()
|
||||
path := usr.HomeDir + "/.asciinema/config"
|
||||
homeDir := os.Getenv("HOME")
|
||||
if homeDir == "" {
|
||||
return nil, errors.New("Need $HOME")
|
||||
}
|
||||
|
||||
cfg, err := loadConfigFile(path)
|
||||
cfgPath := filepath.Join(homeDir, ".asciinema", "config")
|
||||
|
||||
cfg, err := loadConfigFile(cfgPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user