...

Source file src/github.com/ory/x/pkgerx/file.go

Documentation: github.com/ory/x/pkgerx

     1  package pkgerx
     2  
     3  import (
     4  	"io/ioutil"
     5  
     6  	"github.com/ory/x/ioutilx"
     7  
     8  	"github.com/markbates/pkger/pkging"
     9  )
    10  
    11  // MustRead reads a pkging.File or panics.
    12  func MustRead(f pkging.File, err error) []byte {
    13  	if err != nil {
    14  		panic(err)
    15  	}
    16  	defer f.Close()
    17  	return ioutilx.MustReadAll(f)
    18  }
    19  
    20  // Read reads a pkging.File or returns an error
    21  func Read(f pkging.File, err error) ([]byte, error) {
    22  	if err != nil {
    23  		return nil, err
    24  	}
    25  	defer f.Close()
    26  	return ioutil.ReadAll(f)
    27  }
    28  

View as plain text