actions / setup-go

Set up your GitHub Actions workflow with a specific version of Go
MIT License
1.41k stars 531 forks source link

readme: recommend double rather than single quotes in YAML files #513

Open mcandre opened 1 week ago

mcandre commented 1 week ago

Description:

YAML breaks conventions for escape characters in at least one of its three string syntaxes. For this reason, recommend using double quotes ("test") for string values, rather than single quotes ('test') or bare, unquoted strings (test).

Action version:

N/A

Platform:

N/A

Runner type:

N/A

Tools version:

N/A

https://yaml.org/spec/

gowridurgad commented 1 week ago

Hello @mcandre , Thank you for creating this issue. We will investigate it and provide feedback as soon as we have some updates.

priyagupta108 commented 2 days ago

Hi @mcandre 👋, The YAML specification doesn't seem to specifically encourage using double quotes. In YAML, both single quotes ' and double quotes " can be used to denote string values, but they have different behaviors:

The choice between single and double quotes depends on the specific use case. If you need to include escape sequences in your string, you should use double quotes. If you want your string to be interpreted exactly as it is, you should use single quotes. Single quoted strings work for all scenarios In general.

Both quoting styles are widely accepted and used in YAML files. The choice between them often comes down to personal preference and the specific needs of your project. Therefore, there is nothing incorrect about the usage in the README file.

mcandre commented 1 day ago

Anything other than double quote syntax for YAML strings is hazardous and unintuitive.

The spec should deprecate non-double quote syntax in the interest of safety.

priyagupta108 commented 9 hours ago

Thank you for sharing your perspective, but I’d like to clarify that the YAML specification does not deprecate single quote syntax, and both single and double quotes are valid for string values, depending on the use case.

That said, I’m curious—is there a broader consensus or any official documentation suggesting that non-double quote syntax should be deprecated for safety reasons or that it’s generally hazardous? I’d really appreciate any resources or documentation you can provide on this.