Skip to content

x/tools/cmd/goimports: package clause insertion mangles comments #12097

@josharian

Description

@josharian

Input:

// a
// b
// c

func main() {
    fmt.Println()
}

gofmt fails appropriately:

$ gofmt x.go 
x.go:5:1: expected 'package', found 'func'

goimports inserts a package clause and mangles the comments:

$ goimports x.go 
package main // a
import "fmt"

// b
// c

func main() {
    fmt.Println()
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions