This repository has been archived on 2022-03-09. You can view files and clone it, but cannot push or open issues or pull requests.
snoo2nebby/vendor/github.com/turnage/redditproto/loader.go

20 lines
384 B
Go

package redditproto
import (
"bytes"
"io/ioutil"
"github.com/golang/protobuf/proto"
)
// Load reads a user agent from a protobuffer file and returns it.
func Load(filename string) (*UserAgent, error) {
buf, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
agent := &UserAgent{}
return agent, proto.UnmarshalText(bytes.NewBuffer(buf).String(), agent)
}