读取字节数组直到换行 - golang

Read array of byte until new line - golang

我想从 S3 读取文件。这个文件有好几行,每一行都有一个字符串。

类似于:

Alice
Bob
Jack

我有一个 API 读取我的文件,但输出是:[]byte

如何用新行拆分字节数组并将它们转换为字符串?我的 Desire 输出是一个字符串数组。

要从一段字节创建一段字符串,convert the slice of bytes to a string and split换行符上的字符串:

 lines := strings.Split(string(fileContents), "\n")