diff --git a/cli/compose/types/types.go b/cli/compose/types/types.go index 011353f7f8..83d72423fd 100644 --- a/cli/compose/types/types.go +++ b/cli/compose/types/types.go @@ -351,7 +351,7 @@ func (u UnitBytes) MarshalYAML() (any, error) { // MarshalJSON makes UnitBytes implement json.Marshaler func (u UnitBytes) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf(`"%d"`, u)), nil + return fmt.Appendf(nil, `"%d"`, u), nil } // RestartPolicy the service restart policy @@ -561,7 +561,7 @@ func (e External) MarshalJSON() ([]byte, error) { if e.Name == "" { return []byte(strconv.FormatBool(e.External)), nil } - return []byte(fmt.Sprintf(`{"name": %q}`, e.Name)), nil + return fmt.Appendf(nil, `{"name": %q}`, e.Name), nil } // CredentialSpecConfig for credential spec on Windows diff --git a/cli/config/credentials/native_store_test.go b/cli/config/credentials/native_store_test.go index cb31071e60..02c85dbcfb 100644 --- a/cli/config/credentials/native_store_test.go +++ b/cli/config/credentials/native_store_test.go @@ -73,10 +73,10 @@ func (m *mockCommand) Output() ([]byte, error) { return []byte("program failed"), errCommandExited } case "list": - return []byte(fmt.Sprintf(`{"%s": "%s", "%s": "%s"}`, validServerAddress, "foo", validServerAddress2, "")), nil + return fmt.Appendf(nil, `{"%s": "%s", "%s": "%s"}`, validServerAddress, "foo", validServerAddress2, ""), nil } - return []byte(fmt.Sprintf("unknown argument %q with %q", m.arg, inS)), errCommandExited + return fmt.Appendf(nil, "unknown argument %q with %q", m.arg, inS), errCommandExited } // Input sets the input to send to a remote credentials helper.