github.com/defang-io/defang/src@v0.0.0-20240505002154-bdf411911834/pkg/cli/client/state.go (about)

     1  package client
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"runtime"
     7  
     8  	"github.com/defang-io/defang/src/pkg"
     9  )
    10  
    11  func userStateDir() (string, error) {
    12  	if runtime.GOOS == "windows" {
    13  		return os.UserCacheDir()
    14  	} else {
    15  		home, err := os.UserHomeDir()
    16  		return pkg.Getenv("XDG_STATE_HOME", filepath.Join(home, ".local/state")), err
    17  	}
    18  }
    19  
    20  var (
    21  	stateDir, _ = userStateDir()
    22  	// StateDir is the directory where the state file is stored
    23  	StateDir = filepath.Join(stateDir, "defang")
    24  )
    25  
    26  type State struct {
    27  	AnonID string
    28  }