diff --git a/v1/config/file.go b/v1/config/file.go index d1862261..b106df6b 100644 --- a/v1/config/file.go +++ b/v1/config/file.go @@ -49,8 +49,14 @@ func ReadFromFile(cnfPath string) ([]byte, error) { return nil, fmt.Errorf("Open file error: %s", err) } + fileInfo, err := file.Stat() + if err != nil { + return nil, fmt.Errorf("Get file info error: %s", err) + } + length := fileInfo.Size() + // Config file found, let's try to read it - data := make([]byte, 1000) + data := make([]byte, length) count, err := file.Read(data) if err != nil { return nil, fmt.Errorf("Read from file error: %s", err) diff --git a/v2/config/file.go b/v2/config/file.go index acc19034..0910b87b 100644 --- a/v2/config/file.go +++ b/v2/config/file.go @@ -49,8 +49,14 @@ func ReadFromFile(cnfPath string) ([]byte, error) { return nil, fmt.Errorf("Open file error: %s", err) } + fileInfo, err := file.Stat() + if err != nil { + return nil, fmt.Errorf("Get file info error: %s", err) + } + length := fileInfo.Size() + // Config file found, let's try to read it - data := make([]byte, 1000) + data := make([]byte, length) count, err := file.Read(data) if err != nil { return nil, fmt.Errorf("Read from file error: %s", err)