matm / gocov-html

Make pretty HTML output from gocov, a coverage testing tool for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: ... /gocov-html@v1.3.0/pkg/themes/theme.go:9:2: cannot use defaultTheme{

ehwg opened this issue · comments

Hi @matm, is it possible that your latest commits introduced a regression issue.
When I want to install your package
go install github.com/matm/gocov-html/cmd/gocov-html@latest
I am getting following error:

github.com/matm/gocov-html/pkg/themes

../gopath/pkg/mod/github.com/matm/gocov-html@v1.3.0/pkg/themes/theme.go:9:2: cannot use defaultTheme{} (value of type defaultTheme) as types.Beautifier value in array or slice literal: defaultTheme does not implement types.Beautifier (missing method Data)

../gopath/pkg/mod/github.com/matm/gocov-html@v1.3.0/pkg/themes/theme.go:10:2: cannot use kitTheme{} (value of type kitTheme) as types.Beautifier value in array or slice literal: kitTheme does not implement types.Beautifier (missing method Data)

../gopath/pkg/mod/github.com/matm/gocov-html@v1.3.0/pkg/themes/theme.go:14:33: cannot use defaultTheme{} (value of type defaultTheme) as types.Beautifier value in variable declaration: defaultTheme does not implement types.Beautifier (missing method Data)

Shall I use earlier version?

Best regards
Eckard.

+1

Same issue here

Hi guys, not a regression.

The build instructions have changed, please look at the README file. A generator in cmd/generator has to be built and used by a call to go generate ./... before go build the program. Running make (or make build) does the proper calls.

So a single go install call on the repo won't work anymore. The build process now requires an extra step. This is a documented breaking change, you might want to explicitely use version 1.2.0 until you make the change:

$ go install github.com/matm/gocov-html/cmd/gocov-html@v1.2.0

However the instructions to make the change are simple. From v1.3.0+ you can

$ git clone https://github.com/matm/gocov-html.git
$ cd gocov-html
$ make

or if you don't want to use make:

$ git clone https://github.com/matm/gocov-html.git && \
    cd gocov-html && \
    go build github.com/matm/gocov-html/cmd/generator && \
    go generate ./... && \
    go install github.com/matm/gocov-html/cmd/gocov-html

Hope this help.

Also, a working Dockerfile would be:

FROM golang:1.19-alpine3.16

RUN apk update && apk add git
RUN go install github.com/axw/gocov/gocov@latest
RUN git clone https://github.com/matm/gocov-html.git && \
        cd gocov-html && \
        go build github.com/matm/gocov-html/cmd/generator && \
        go generate ./... && \
        go install github.com/matm/gocov-html/cmd/gocov-html

Then

$ docker build -t tool .
$ docker run --rm tool gocov-html -h

@matm Adding breaking changes should increment major version rather than minor.

Why go installable tool requires a clone?

As proposed by @obalunenko on #38, I think it makes sense to keep/version the generated code. That would prevent breaking the go install command.

Do you guys agree?

Hi @matm I tried to do the clone and generate but it did not work out of the box in my (azure)pipeline, neither with the make nor with the generate. So I went back to 1.2.0 which worked: go install github.com/matm/gocov-html/cmd/gocov-html@v1.2.0.

I would agree to keep/version the generated code. If I would like to use my own css then I would need to clone it and generate, right? I think generating the code in the pipeline again and again would not be a good option for me.

@ehwg I'm on it, 1.3.1 will work as usual with go install (see #47).

If I would like to use my own css then I would need to clone it and generate, right?

No, you can use a custom CSS file using the -s flag.

v1.3.1 just released and fixes this annoying issue. go install works as usual now.
Thanks for your feedback guys.

Thanks for the update