Open thijsheijden opened 1 year ago
To reproduce the bug, run golines on this file and notice how “pattern” changes.
package main
import "fmt"
type foo struct {
Name string `jsonschema:"pattern=^[^\\-<>%{}\\[\\]&#\\\\\\\"]+$"`
}
func main() {
// The below forces golines to rewrite the file and in doing so it changes the foo.Name field's "pattern"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa := 1
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb := 1
if aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb == 2 {
fmt.Println("true")
}
}
Even if the regular expression is invalid, the tool should not try to change it.
I have the following struct tag:
jsonschema:"title=Title,minLength=1,maxLength=40,pattern=^[^\\-<>%{}\\[\\]&#\\\\\\\"]+$"
, and upon runninggolines ${file} -w -m 120
using theRun on Save
extension in VSCode, the tag is changed intojsonschema:"title=title=Title,maxLength=40,pattern=^[^\-<>%{}\[\]&#\\\"]+$"
, turning it into an invalid struct tag.