github.com/lestrrat-go/jwx/v2@v2.0.21/jws/io.go (about)

     1  // Code generated by tools/cmd/genreadfile/main.go. DO NOT EDIT.
     2  
     3  package jws
     4  
     5  import (
     6  	"io/fs"
     7  	"os"
     8  )
     9  
    10  type sysFS struct{}
    11  
    12  func (sysFS) Open(path string) (fs.File, error) {
    13  	return os.Open(path)
    14  }
    15  
    16  func ReadFile(path string, options ...ReadFileOption) (*Message, error) {
    17  
    18  	var srcFS fs.FS = sysFS{}
    19  	for _, option := range options {
    20  		switch option.Ident() {
    21  		case identFS{}:
    22  			srcFS = option.Value().(fs.FS)
    23  		}
    24  	}
    25  
    26  	f, err := srcFS.Open(path)
    27  	if err != nil {
    28  		return nil, err
    29  	}
    30  
    31  	defer f.Close()
    32  	return ParseReader(f)
    33  }