Skip to content

Go snippet evolution #448

Open
Open
@ccoVeille

Description

@ccoVeille

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

f, err := strconv.Atoi("42")
if err != nil {

    panic(err) }

fmt.Println(f +3,
)

Here the code is badly formatted on purpose.

This snippet cannot work with the following solution.

Here is what could be done

  • add the same header, as you already do now
  • test if it works, great
  • if fails, enclose the code with this
package main

func main() {

// a random string
<insert the code snippet here>
// the same random string
}
  • try to format
  • if it works, use code to extract everything between the random strings delimiter
  • trim the leading space on each line returned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions