flowRoot returns the root directory for flow state. Honors $FLOW_ROOT if set, otherwise falls back to ~/.flow. The returned path is not guaranteed to exist — callers that need it created should run `flow init` or create it themselves.
()
| 12 | // to exist — callers that need it created should run `flow init` or create |
| 13 | // it themselves. |
| 14 | func flowRoot() (string, error) { |
| 15 | if r := os.Getenv("FLOW_ROOT"); r != "" { |
| 16 | return r, nil |
| 17 | } |
| 18 | home, err := os.UserHomeDir() |
| 19 | if err != nil { |
| 20 | return "", fmt.Errorf("no home dir: %w", err) |
| 21 | } |
| 22 | return filepath.Join(home, ".flow"), nil |
| 23 | } |
| 24 | |
| 25 | // flowDBPath returns the absolute path to flow.db under the flow root. |
| 26 | // Returns a clear error if the data directory hasn't been initialized. |
no outgoing calls