How to write interpolated string
- Dominant language
- Go
- Stars
- 5.8k
- Forks
- 657
- Avg merge
- 20h 36m
- Merged PRs (30d)
- 6
Description
Currently I write string values as: `body.SetAttributeValue("name", cty.StringVal(name))`
Now I want to support writing interpolations. So if `name` contains `${var.foo}`, I would like attribute to be`name = "${var.foo}"`.
Sadly it seems like `SetAttributeValue` is always escaping the interpolation as `name = "$${var.foo}"`.
I tried
```
body.SetAttributeRaw("name", hclwrite.Tokens{
&hclwrite.Token{
Type: hclsyntax.TokenApostrophe,
Bytes: []byte(name),
},
})
```
but lose the quoting then.
I have not yet figured out how to write a unescaped interpolated string.
Maybe someone could give me a hint.
~~Looking at the source code, it seems like there is no single test case for producing `$$` :(~~ Versioning threw me off. Found the tests.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the SetAttributeValue and SetAttributeRaw implementations and the existing interpolation or escaping tests mentioned in the issue. Determine how quoted interpolated strings should be represented, then add coverage showing the desired output preserves `${var.foo}` without producing `$${var.foo}`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100