(name string, ignoreMissing bool)
| 499 | var gnupgHome string |
| 500 | |
| 501 | func loadKeyRing(name string, ignoreMissing bool) (openpgp.EntityList, error) { |
| 502 | // if path doesn't contain slashes, treat it as relative to GnuPG home directory |
| 503 | if !strings.Contains(name, "/") { |
| 504 | name = filepath.Join(gnupgHome, name) |
| 505 | } |
| 506 | |
| 507 | f, err := os.Open(name) |
| 508 | if err != nil { |
| 509 | if os.IsNotExist(err) { |
| 510 | if !ignoreMissing { |
| 511 | fmt.Printf("opengpg: failure opening keyring '%s': %s\n", name, err) |
| 512 | } |
| 513 | return nil, nil |
| 514 | } |
| 515 | |
| 516 | return nil, err |
| 517 | } |
| 518 | defer func() { |
| 519 | _ = f.Close() |
| 520 | }() |
| 521 | |
| 522 | return openpgp.ReadKeyRing(f) |
| 523 | } |
| 524 | |
| 525 | func init() { |
| 526 | gnupgHome = os.Getenv("GNUPGHOME") |
no test coverage detected