]> Cypherpunks repositories - gostls13.git/commit
go/ast: fix SortImports to handle block comments (take 2)
authorAgniva De Sarker <agnivade@yahoo.co.in>
Wed, 13 Feb 2019 03:19:52 +0000 (08:49 +0530)
committerRobert Griesemer <gri@golang.org>
Mon, 28 Oct 2019 23:33:26 +0000 (23:33 +0000)
commitbf670bd83c849b56426c63b49f28121210a627ca
tree9767ee757e3f90b745adb599516c7968e9d199c3
parent59a684703913e383c482c1383b2d4958c674248c
go/ast: fix SortImports to handle block comments (take 2)

This is a 2nd attempt at fixing CL 162337 which had an off-by-one error.
We were unconditionally getting the position of the start of the next line
from the last import without checking whether it is the end of the file or not.

Fix the code to check for that and move the testcase added in CL 190523
to the end of the file for it to trigger the issue properly.

Fixes #18929

Change-Id: I59e77256e256570b160fea6a17bce9ef49e810df
Reviewed-on: https://go-review.googlesource.com/c/go/+/190480
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/gofmt/testdata/import.golden
src/cmd/gofmt/testdata/import.input
src/go/ast/import.go