Open seiyab opened 7 months ago
I think DefaultParameters tend to be unintentionally mutated. Because DefaultParameters is a pointer, following code will pollute it.
DefaultParameters
params := winrm.DefaultParameters params.Timeout = timeout // ⚠️ Ouch! winrm.DefaultParameters is also changed!
You can see such codes even in README.md. https://github.com/masterzen/winrm/blob/e811dad5ac77d4d981dc85fd43a587843274bca0/README.md#L139-L140
I also put a real-world example here. https://github.com/hashicorp/terraform/blob/8f7744da0959334f461c18ccf15f8b19d8c09fe6/internal/communicator/winrm/communicator.go#L63-L64
I suggest to add something like NewDefaultParameters() and add // Deprecated into DefaultParameters.
NewDefaultParameters()
// Deprecated
I think
DefaultParameters
tend to be unintentionally mutated. BecauseDefaultParameters
is a pointer, following code will pollute it.You can see such codes even in README.md. https://github.com/masterzen/winrm/blob/e811dad5ac77d4d981dc85fd43a587843274bca0/README.md#L139-L140
I also put a real-world example here. https://github.com/hashicorp/terraform/blob/8f7744da0959334f461c18ccf15f8b19d8c09fe6/internal/communicator/winrm/communicator.go#L63-L64