Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Usage of errCheck

Igor Maznitsa edited this page Mar 3, 2017 · 2 revisions

It is possible to use the errCheck Golang tool with the plugin. For such cases the plugin provides the custom goal (it allows to start some executable golang tool) and adapted example of errCheck usage will look like

      <plugin>
        <groupId>com.igormaznitsa</groupId>
        <artifactId>mvn-golang-wrapper</artifactId>
        <version>${mvn.golang.version}</version>
        <extensions>true</extensions>
        <configuration>
          <goVersion>${go.sdk.version}</goVersion>
        </configuration>
        <executions>
          <execution>
            <id>get-err-check</id>
            <goals>
              <goal>get</goal>
            </goals>
            <configuration>
              <packages>
                <package>github.com/kisielk/errcheck</package>
              </packages>
            </configuration>
          </execution>
          <execution>
            <goals>
              <goal>custom</goal>
            </goals>
            <phase>verify</phase>
            <configuration>
              <exec>errcheck</exec>
              <buildFlags>
                <flag>-blank</flag>
              </buildFlags>
            </configuration>
          </execution>
        </executions>
      </plugin>

errCheck prints messages into standard stream and the result will look like

--- mvn-golang-wrapper:2.1.2:custom (default) @ golangIntegrateErrCheck ---
Prepared command line : bin/errcheck -blank

---------Exec.Out---------
main.go:13:8:	file, _ := os.Open(path)
main.go:14:12:	file.Write([]byte(data))
main.go:15:12:	file.Close()

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Clone this wiki locally