File: decode_go116.go

package info (click to toggle)
golang-toml 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,904 kB
  • sloc: makefile: 4
file content (19 lines) | stat: -rw-r--r-- 358 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//go:build go1.16
// +build go1.16

package toml

import (
	"io/fs"
)

// DecodeFS reads the contents of a file from [fs.FS] and decodes it with
// [Decode].
func DecodeFS(fsys fs.FS, path string, v interface{}) (MetaData, error) {
	fp, err := fsys.Open(path)
	if err != nil {
		return MetaData{}, err
	}
	defer fp.Close()
	return NewDecoder(fp).Decode(v)
}