[Bug?] Error when running "go tool cover" on package name contains dot

419 views
Skip to first unread message

Shulhan

unread,
Aug 19, 2018, 11:47:37 AM8/19/18
to golan...@googlegroups.com
Running "go tool cover" on package name contains dot with Go 1.11rc1
or latest dev on branch master return an error, but success on Go
1.10.3.

Steps to reproduces

- Create package name with dot ('.').
- Create minimal test file
- Generate test coverage profile,

go test -count=1 -coverprofile=cover.out ./...

- Generate HTML coverage,

go tool cover -html=cover.out -o cover.html


Actual Result

```
22:44 ~/tmp/sandbox/go/src/bug/gotoolcover.go
master ms 1 % go version
go version devel +bf80e3b564 Sat Aug 18 18:23:06 2018 +0000 linux/amd64

22:44 ~/tmp/sandbox/go/src/bug/gotoolcover.go
master ms 0 % go test -count=1 -coverprofile=cover.out ./...
ok bug/gotoolcover.go 0.001s coverage: 0.0% of statements
[no tests to run]

22:44 ~/tmp/sandbox/go/src/bug/gotoolcover.go
master ms 0 % go tool cover -html=cover.out -o cover.html
cover: cannot run go list: exit status 1
stat bug/gotoolcover.go: no such file or directory
```


Expected result

Running on package name without dot,

```
22:45 ~/tmp/sandbox/go/src/bug/gotoolcover-go
master ms 0 % go version
go version devel +bf80e3b564 Sat Aug 18 18:23:06 2018 +0000 linux/amd64

22:45 ~/tmp/sandbox/go/src/bug/gotoolcover-go
master ms 0 % go test -count=1 -coverprofile=cover.out ./...
ok bug/gotoolcover-go 0.001s coverage: 0.0% of statements
[no tests to run]

22:45 ~/tmp/sandbox/go/src/bug/gotoolcover-go
master ms 0 % go tool cover -html=cover.out -o cover.html
```

Should I report this as an issue?

Dave Cheney

unread,
Aug 19, 2018, 7:13:00 PM8/19/18
to golang-nuts
Point of clarification, the package name doesn’t contain a dot, that is not permitted by the syntax of the package declaration. The name of the directory you placed the file in ends in .go and this is confusing the tool.

If this is a regression from an earlier version of Go, please raise an issue.

Thanks

Dave

Shulhan

unread,
Aug 20, 2018, 4:42:18 AM8/20/18
to Dave Cheney, golang-nuts
On Sun, 19 Aug 2018 16:13:00 -0700 (PDT)
Dave Cheney <da...@cheney.net> wrote:

> Point of clarification, the package name doesn’t contain a dot, that
> is not permitted by the syntax of the package declaration. The name
> of the directory you placed the file in ends in .go and this is
> confusing the tool.
>

Sorry, I write a misleading words in previous message. I wrote
"package name" where it should be "directory name".

> If this is a regression from an earlier version of Go, please raise
> an issue.
>

There is no problem when tested with Go v1.10.3. I will report it
later, thank you for checking this.

Dave Cheney

unread,
Aug 20, 2018, 5:28:34 AM8/20/18
to Shulhan, golang-nuts
Thanks for confirming this is a regression.
Reply all
Reply to author
Forward
0 new messages