antonmarin/secret-yaml

View on GitHub
io/file.go

Summary

Maintainability
A
0 mins
Test Coverage
B
83%
package io

import "io/ioutil"

type file struct {
    path string
}

func (file file) AsBytes() ([]byte, error) {
    return ioutil.ReadFile(file.path)
}
func (file file) AsString() (string, error) {
    bytes, err := ioutil.ReadFile(file.path)
    if err != nil {
        return "", err
    }

    return string(bytes), nil
}

//NewFile creates new file input
func NewFile(path string) *file {
    return &file{path: path}
}