Open ccoVeille opened 1 month ago
So if I understand it correctly the issue is that code must be inside a function definition?
The only "issue" I can see from this is that mdsf would also have to handle removing the extra indentation, which varies depending on formatter and configuration.
Yes, exactly. I knew my suggestion is a bit messy, but I'm afraid I don't see another solution right now.
And the issue will also be that the formatting will import the path.
So this
f, err := strconv.Atoi("42")
if err != nil {
panic(err) }
fmt.Println(f +3
)
will have to be written like this before being sent to formatter
package main
func main() {
f, err := strconv.Atoi("42")
if err != nil {
panic(err) }
fmt.Println(f +3,
)
}
https://go.dev/play/p/kMQRuIxEo-Z
would be formatted like this (please note the imports were added)
https://go.dev/play/p/xIBzjl-lUCh
package main
import (
"fmt"
"strconv"
)
func main() {
f, err := strconv.Atoi("42")
if err != nil {
panic(err)
}
fmt.Println(f + 3)
}
So here you would have to extract the content of main
f, err := strconv.Atoi("42")
if err != nil {
panic(err)
}
fmt.Println(f + 3)
and trim the leading spaces
f, err := strconv.Atoi("42")
if err != nil {
panic(err)
}
fmt.Println(f + 3)
That's why I suggested adding comment block to split the text
https://go.dev/play/p/PMDiIRjpvcV
format then split the content between
You already fixed issues with Go code with my previous reported issue
151
I found a new pattern, but I have a new solution.
The example I used where struct, so a type definition,something that works simply by adding a package.
Unfortunately, there are piece of code, that are not formatted, and lead to errors today
Here are example
Here the code is badly formatted on purpose.
This snippet cannot work with the following solution.
Here is what could be done