-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go snippet evolution #448
Comments
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
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
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
The text was updated successfully, but these errors were encountered: