-
Notifications
You must be signed in to change notification settings - Fork 32
"Missing go.sum entry error" when building using Go 1.16 with modules #84
Description
Description
While using Go 1.15 with module support, any error in the go.sum file was automatically fixed during the build phase. However, with Go 1.16, this automatic fix was disabled (see here).
Unfortunately, during build time the go.sum file is deleted and never restored. As a result, building any project using the new Go version yields the following error during any stage of the build:
[ERROR] ---------Exec.Err---------
[ERROR] go: github.com/google/uuid@v1.2.0: missing go.sum entry; to add it:
[ERROR] go mod download github.com/google/uuid
You can find the complete output of mvn clean compile command using a simple Maven project attached to this bug.
Here there is the parent POM of my project (defining the configuration of the mvn-golang-wrapper plugin):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroup</groupId>
<artifactId>mygoproject</artifactId>
<packaging>pom</packaging>
<version>${revision}</version>
<modules>
<module>gomodule</module>
</modules>
<properties>
<revision>0.0.1-SNAPSHOT</revision>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<mvn.golang.version>2.3.7</mvn.golang.version>
<mvn.golang.module.mode>true</mvn.golang.module.mode>
<go.sdk.version>1.16.2</go.sdk.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>mvn-golang-wrapper</artifactId>
<version>${mvn.golang.version}</version>
<extensions>true</extensions>
<configuration>
<goVersion>${go.sdk.version}</goVersion>
<disableSdkLoad>true</disableSdkLoad>
<goRoot>/usr/lib/go</goRoot>
<moduleMode>true</moduleMode>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>This is the child POM that contains basic configuration for the specific module:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mygroup</artifactId>
<groupId>mygoproject</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gomodule</artifactId>
<packaging>mvn-golang</packaging>
<name>Go Module</name>
<build>
<sourceDirectory>${basedir}${file.separator}src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>mvn-golang-wrapper</artifactId>
<configuration>
<resultName>gomodule</resultName>
</configuration>
</plugin>
</plugins>
</build>
</project>Expected result
The go.sum file is never deleted during any phase if the Go SDK version is equal or greater 1.16, because the file is not automatically restored.
Actual result
The go.sum file is always deleted during build time, yielding the mentioned error for Go SDK >= 1.16.
Temporary workaround
If the automatic download of the SDK is enabled and the version of the SDK is set to a version prior to 1.16 (namely: 1.15.8), the same configuration works because the missing go.sum file is autimatically handled during build time.