segmentio / golines

A golang formatter that fixes long lines
MIT License
903 stars 56 forks source link

golines may output invalid code when \n is present in a struct tag. #134

Open EricIO opened 3 months ago

EricIO commented 3 months ago

For the input

package main

type Foo struct {
    Bar []string `parameter:"BAR" delimiter:"\n"`
}

golines will output the following invalid go code.

package main

type Foo struct {
    Bar []string `param:"CLIENT" delimiter:"
"`
}

Interestingly removing the first tag part will make golines output correctly formated code.

package main

type Foo struct {
    Bar []string `delimiter:"\n"`
}

outputs

package main

type Foo struct {
    Bar []string `delimiter:"\n"`
}