Skip to content

dst removes line break between /* … */ comments and package statement #69

Closed
@stapelberg

Description

@stapelberg

When taking the example program from the README, and adding a /* single line comment */ like so:

package main

import "github.com/dave/dst/decorator"

func main() {
	code := `/* single line comment */
package a

func main(){
	var a int    // foo
	var b string // bar
}
`
	f, err := decorator.Parse(code)
	if err != nil {
		panic(err)
	}
	if err := decorator.Print(f); err != nil {
		panic(err)
	}
}

…the output is:

/* single line comment */package a

func main() {
	var a int    // foo
	var b string // bar
}

Note how package a is now at the end of the previous line.

The same issue is reproducible with multi-line /* … */ comments.

I tested this with github.com/dave/dst v0.27.0, which is current at the time of writing.

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