golang formatter: problem when code snippet is not a full file
ccoVeille opened this issue ยท comments
```go
var err = errors.New("dddd")
type Whatever struct {
StartAt time.Time `json:"start_at"`
End time.Time `json:"end_at"`
Delete bool `json:-"`
}
```
golang can only be formatted with tools if the file is valid.
So if the linting doesn't work you can try to add this to the begining of the file
```go
package main
// REMOVE ANYTHING ABOVE THIS
var err = errors.New("dddd")
type Whatever struct {
StartAt time.Time `json:"start_at"`
End time.Time `json:"end_at"`
Delete bool `json:-"`
}
```
mdsf will then be able to format like this
```go
package main
// REMOVE ANYTHING ABOVE THIS
var err = errors.New("dddd")
type Whatever struct {
StartAt time.Time `json:"start_at"`
End time.Time `json:"end_at"`
Delete bool `json:-"`
}
```
Then if you trim the code then
```go
var err = errors.New("dddd")
type Whatever struct {
StartAt time.Time `json:"start_at"`
End time.Time `json:"end_at"`
Delete bool `json:-"`
}
```
It would be a more fail proof hack but quite an hack
Good catch ๐
I believe #154 should fix the issue. It passes tests for both with and without package name ๐
I'll check by running on my documentation codebase.
Good catch ๐
I hope you are finding all my feedback useful. I hope I'm a good alpha/beta tester ๐
You are an amazing bug finder โค๏ธ
I found a possible edge case
I'll check by running on my documentation codebase.
It works as expected