go: cmd/cover: panic: overlapping edits

Hello all with the latest RC if i run tests all is ok, if I run them with coverage I run into this error:

cover poc/all_test
panic: overlapping edits: [4371,4375)->"", [4372,4372)->"_cover_atomic_.AddUint32(&GoCover_2_646536633930623366336461.Count[26], 1);"

goroutine 1 [running]:
cmd/internal/edit.(*Buffer).Bytes(0xc0421223c0, 0xc0420421e0, 0x63b4a0, 0xc0420ee580)
	C:/workdir/go/src/cmd/internal/edit/edit.go:79 +0x51c
main.annotate(0xc042044060, 0x53)
	C:/workdir/go/src/cmd/cover/cover.go:332 +0x46f
main.main()
	C:/workdir/go/src/cmd/cover/cover.go:88 +0x187 ```

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks. The problem only arises because your main.go file has not been through gofmt. If I run gofmt on the file, the problem disappears.

The problem is specifically }else{. If I change that to } else{ (adding a space after the }, as gofmt does) then the problem does not occur.

main.go:

package main

func main(){
	var attributes []string
	var item interface{}

	if len(attributes) > 0{
		if item != nil{
			//DO SOMETHING
		}
	}else{
		//DO SOMETHING
	}
}

main_test.go:

package main

import (
	"testing"
)

func TestMain(t *testing.T) {
	main()
}

go test -cover

# cover _/tmp/x/src/a
panic: overlapping edits: [142,146)->"", [143,143)->"GoCover_0_366235663035346337313436.Count[3] = 1;"

goroutine 1 [running]:
cmd/internal/edit.(*Buffer).Bytes(0xc0000f2c00, 0xc0000f0120, 0x6216a0, 0xc000110300)
	/home/iant/go/src/cmd/internal/edit/edit.go:79 +0x515
main.annotate(0x7ffeec2bb74a, 0x14)
	/home/iant/go/src/cmd/cover/cover.go:332 +0x468
main.main()
	/home/iant/go/src/cmd/cover/cover.go:88 +0x180
FAIL	_/tmp/x/src/a [build failed]