@@ -52,6 +52,15 @@ func (l *Loader) LoadBytes(buf []byte) (*Properties, error) {
52
52
return l .loadBytes (buf , l .Encoding )
53
53
}
54
54
55
+ // LoadReader reads an io.Reader into a Properties struct.
56
+ func (l * Loader ) LoadReader (r io.Reader ) (* Properties , error ) {
57
+ if buf , err := io .ReadAll (r ); err != nil {
58
+ return nil , err
59
+ } else {
60
+ return l .loadBytes (buf , l .Encoding )
61
+ }
62
+ }
63
+
55
64
// LoadAll reads the content of multiple URLs or files in the given order into
56
65
// a Properties struct. If IgnoreMissing is true then a 404 status code or
57
66
// missing file will not be reported as error. Encoding sets the encoding for
@@ -185,6 +194,12 @@ func LoadFile(filename string, enc Encoding) (*Properties, error) {
185
194
return l .LoadAll ([]string {filename })
186
195
}
187
196
197
+ // LoadReader reads an io.Reader into a Properties struct.
198
+ func LoadReader (r io.Reader , enc Encoding ) (* Properties , error ) {
199
+ l := & Loader {Encoding : enc }
200
+ return l .LoadReader (r )
201
+ }
202
+
188
203
// LoadFiles reads multiple files in the given order into
189
204
// a Properties struct. If 'ignoreMissing' is true then
190
205
// non-existent files will not be reported as error.
@@ -224,6 +239,12 @@ func MustLoadString(s string) *Properties {
224
239
return must (LoadString (s ))
225
240
}
226
241
242
+ // MustLoadSReader reads an io.Reader into a Properties struct and
243
+ // panics on error.
244
+ func MustLoadReader (r io.Reader , enc Encoding ) * Properties {
245
+ return must (LoadReader (r , enc ))
246
+ }
247
+
227
248
// MustLoadFile reads a file into a Properties struct and
228
249
// panics on error.
229
250
func MustLoadFile (filename string , enc Encoding ) * Properties {
0 commit comments