File: decode_go116.go

package info (click to toggle)
golang-toml 0.4.1%2Bgit20210923.e0af6a2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,028 kB
  • sloc: makefile: 13; python: 11
file content (18 lines) | stat: -rw-r--r-- 381 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// +build go1.16

package toml

import (
	"io/fs"
)

// DecodeFS is just like Decode, except it will automatically read the contents
// of the file at `path` from a fs.FS instance.
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)
}