diff options
| author | Adnan Maolood <[email protected]> | 2021-01-14 17:09:31 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-01-14 17:09:31 -0500 |
| commit | 3fd55c5ceede90b3d57bc1bde41bba5e5325e345 (patch) | |
| tree | 373438e6d49f6eecf5ae26596c1035d086bb7fa2 /tofu | |
| parent | tofu: Add NewHostsFile function (diff) | |
| download | go-gemini-3fd55c5ceede90b3d57bc1bde41bba5e5325e345.tar.xz go-gemini-3fd55c5ceede90b3d57bc1bde41bba5e5325e345.zip | |
tofu: Add KnownHosts.Load function
Diffstat (limited to 'tofu')
| -rw-r--r-- | tofu/tofu.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tofu/tofu.go b/tofu/tofu.go index 9954734..0fd7d26 100644 --- a/tofu/tofu.go +++ b/tofu/tofu.go @@ -67,6 +67,17 @@ func (k *KnownHosts) WriteTo(w io.Writer) (int64, error) { return int64(written), bw.Flush() } +// Load loads the known hosts entries from the provided path. +func (k *KnownHosts) Load(path string) error { + f, err := os.Open(path) + if err != nil { + return err + } + defer f.Close() + + return k.Parse(f) +} + // Parse parses the provided io.Reader and adds the parsed hosts to the list. // Invalid entries are ignored. // |