mirror of
				https://github.com/SSLMate/certspotter.git
				synced 2025-07-03 10:47:17 +02:00 
			
		
		
		
	Use os.UserHomeDir to determine home directory
Go provides this since Go 1.12; no need to reinvent the wheel.
This commit is contained in:
		
							parent
							
								
									3d1bdb2b60
								
							
						
					
					
						commit
						33ebbdfd07
					
				@ -16,7 +16,6 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
	"os"
 | 
			
		||||
	"os/user"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"sync"
 | 
			
		||||
 | 
			
		||||
@ -41,15 +40,11 @@ var state *State
 | 
			
		||||
var printMutex sync.Mutex
 | 
			
		||||
 | 
			
		||||
func homedir() string {
 | 
			
		||||
	home := os.Getenv("HOME")
 | 
			
		||||
	if home != "" {
 | 
			
		||||
		return home
 | 
			
		||||
	homedir, err := os.UserHomeDir()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(fmt.Errorf("unable to determine home directory: %w", err))
 | 
			
		||||
	}
 | 
			
		||||
	user, err := user.Current()
 | 
			
		||||
	if err == nil {
 | 
			
		||||
		return user.HomeDir
 | 
			
		||||
	}
 | 
			
		||||
	panic("Unable to determine home directory")
 | 
			
		||||
	return homedir
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func DefaultStateDir(programName string) string {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user