Skip to content

Instantly share code, notes, and snippets.

@YagmurOzden
Created December 1, 2022 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YagmurOzden/77cdfd643fc2c30b5d645c82495dab78 to your computer and use it in GitHub Desktop.
Save YagmurOzden/77cdfd643fc2c30b5d645c82495dab78 to your computer and use it in GitHub Desktop.
For reading files that are bytes. GOLang
// For reading files that are bytes
func ParseData(file billy.File) string {
log.Printf("%v Started to parse file data to string", APINAME)
buf := make([]byte, 1)
var data string
for {
n, err := file.Read(buf)
if err == io.EOF {
break
}
if err != nil {
log.Printf("%v Cannot read the file. Error: %v", APINAME, err.Error())
continue
}
if n > 0 {
data += string(buf[:n])
}
}
return data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment