Remove some unnecessary []byte to string conversions

Some calls to `Sprintf("%s")` can be avoided by using direct string
type assertions.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
Sascha Grunert
2020-08-03 09:13:04 +02:00
parent bfd34542f4
commit fef3e2da6a
5 changed files with 10 additions and 11 deletions

View File

@ -215,7 +215,7 @@ func (s *PodmanSession) OutputToString() string {
// where each array item is a line split by newline
func (s *PodmanSession) OutputToStringArray() []string {
var results []string
output := fmt.Sprintf("%s", s.Out.Contents())
output := string(s.Out.Contents())
for _, line := range strings.Split(output, "\n") {
if line != "" {
results = append(results, line)
@ -226,14 +226,14 @@ func (s *PodmanSession) OutputToStringArray() []string {
// ErrorToString formats session stderr to string
func (s *PodmanSession) ErrorToString() string {
fields := strings.Fields(fmt.Sprintf("%s", s.Err.Contents()))
fields := strings.Fields(string(s.Err.Contents()))
return strings.Join(fields, " ")
}
// ErrorToStringArray returns the stderr output as a []string
// where each array item is a line split by newline
func (s *PodmanSession) ErrorToStringArray() []string {
output := fmt.Sprintf("%s", s.Err.Contents())
output := string(s.Err.Contents())
return strings.Split(output, "\n")
}