Created
December 1, 2022 06:09
-
-
Save YagmurOzden/77cdfd643fc2c30b5d645c82495dab78 to your computer and use it in GitHub Desktop.
For reading files that are bytes. GOLang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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