reg, _ := regexp.Compile(`\s+`) r := reg.ReplaceAll(resBody, []byte("")) compile string to regexp, then replace all