dominikh / go-simple

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggests raw string even when string contains backtick, which can't be contained in raw strings

ptman opened this issue · comments

IMO it would be more readable to use raw strings + string concatenation for the backtick, instead of needing to escape \ a dozen times.

I'll close this issue. I stand by my earlier opinion, and there hasn't been any activity on this issue to convince me otherwise.

In general, I agree, but I can imagine a worse case scenario where the string value is:

var worstCase = regexp.MustCompile("```\\n")

Would the suggestion still be valid then?

Edit: Perhaps so, because the above can still be rewritten more nicely... Do you agree?

regexp.MustCompile("```" + `\n`)

The first version does look nicer imho. However, we'll cross that bridge when we come to it (i.e. when someone actually has that regular expression in their code.)

However, we'll cross that bridge when we come to it (i.e. when someone actually has that regular expression in their code.)

That's exactly what I was thinking. 👍