INNER CODE UNIT · Go
Open
mvanhorn/agentcookie · cookiesource/cookiesource.go:65
func Open() (Source, error) {
path := os.Getenv(EnvVar)
if path == "" {
return Source{}, nil
}
info, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
return Source{Path: path, PlainText: true}, ErrSidecarMissing
}
return Source{}, fmt.Errorf("cookiesource: stat %s: %w", path, err)
}
if info.IsDir() {
return Source{}, fmt.Errorf("cookiesource: %s is a directory, not a SQLite file", path)
}
return Source{Path: path, PlainText: true}, nil
}