-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Omit go.{mod,sum} from pkg when not in module mode
In certain environments, it's possible to package chaincode that structured as a module from an active GOPATH. This often happens when the path provided to the package command is an import path resolvable from the GOPATH instead of a file system path. If the package could be successfully built in the packaging environment using the import path, the chaincode dependencies would be calculated and packaged from the GOPATH for compilation as a traditional go package. In this scenario, the `go.mod` would be included in the chaincode package as packaging always includes all non-hidden files in the top level folder of the import path. On the server, the presence of the `go.mod` implies that the build process should execute in module mode. When the dependencies have been vendored in the module, the build uses `-mod=vendor` flag to indicate the module requirements should be satisfied from the vendor folder. Unfortunately, since the chaincode dependencies were packaged using GOPATH mode instead of module mode, there are some metadata files missing from the vendor folder that are expected by the module mode build process. To help prevent this from occuring, we will explicitly omit go.mod and go.sum from top level folder of chaincode that is not packaged in module mode. FAB-17725 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com> Change-Id: I5253205ab9c7471beddffec7a11dab987c3acebd
- Loading branch information
Showing
4 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
core/chaincode/platforms/golang/testdata/src/chaincodes/noop/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/hyperledger/fabric/core/chaincode/platforms/golang/testdata/src/chaincodes/noop | ||
|
||
go 1.13 | ||
|
||
// This should not get included in packages that were created from a GOPATH |
2 changes: 2 additions & 0 deletions
2
core/chaincode/platforms/golang/testdata/src/chaincodes/noop/go.sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore/me v0.0.1 h1:0badc0de0badcode | ||
ignore/me v0.0.1/go.mod |