Skip to content

Commit 81eef4d

Browse files
Upgrade to go 1.20 and deps update
Signed-off-by: Marcus Brandenburger <[email protected]> Apply gofmt formatting Signed-off-by: Marcus Brandenburger <[email protected]>
1 parent b413ca5 commit 81eef4d

File tree

57 files changed

+3960
-3277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3960
-3277
lines changed

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ gotools:
4040
# in 'utils/docker/base-dev/Dockerfile')
4141
$(GO) install golang.org/x/tools/cmd/goimports
4242
$(GO) install google.golang.org/protobuf/cmd/protoc-gen-go
43-
GO111MODULE=off $(GO) get github.com/maxbrunsfeld/counterfeiter
44-
$(GO) install honnef.co/go/tools/cmd/[email protected]
45-
$(GO) get -u github.com/client9/misspell/cmd/misspell
43+
$(GO) install honnef.co/go/tools/cmd/[email protected]
44+
$(GO) install github.com/client9/misspell/cmd/misspell
4645

4746
godeps: gotools
4847
$(GO) mod download

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ Make sure that you have the following required dependencies installed:
255255

256256
* CMake v3.5.1 or higher
257257

258-
* [Go](https://golang.org/) 1.17.5 or higher
258+
* [Go](https://golang.org/) 1.20.x or higher
259259

260260
* Docker 18.09 (or higher) and docker-compose 1.25.x (or higher)
261261
Note that version from Ubuntu 18.04 is not recent enough! To upgrade, install a recent version following the instructions from [docker.com](https://docs.docker.com/compose/install/), e.g., for version 1.25.4 execute

client_sdk/go/doc.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SPDX-License-Identifier: Apache-2.0
1010
// The main goal is to ease the interaction with a FPC chaincode and provide similar experience as offered by normal
1111
// chaincode interaction.
1212
//
13-
// Packages for end developer usage
13+
// # Packages for end developer usage
1414
//
1515
// pkg/client/resmgmt: Provides resource management capabilities such as installing FPC chaincode.
1616
// Reference: https://godoc.org/github.com/hyperledger/fabric-private-chaincode/client_sdk/go/pkg/client/resmgmt
@@ -19,9 +19,8 @@ SPDX-License-Identifier: Apache-2.0
1919
// Fabric programming model.
2020
// Reference: https://godoc.org/github.com/hyperledger/fabric-private-chaincode/client_sdk/go/pkg/gateway
2121
//
22-
// Usage samples
22+
// # Usage samples
2323
//
2424
// $FPC_PATH/samples/application: Illustrates the use of the FPC Client SDK.
2525
// The sample applications can be used with our test-network `$FPC_PATH/samples/deployment/test-network`.
26-
//
2726
package fpcclientsdk

client_sdk/go/pkg/client/resmgmt/lifecycleclient.go

+18-19
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,31 @@ SPDX-License-Identifier: Apache-2.0
1111
//
1212
// Example:
1313
//
14-
// adminContext := sdk.Context(fabsdk.WithUser(orgAdmin), fabsdk.WithOrg(orgName))
14+
// adminContext := sdk.Context(fabsdk.WithUser(orgAdmin), fabsdk.WithOrg(orgName))
1515
//
16-
// client, err := resmgmt.New(adminContext)
17-
// if err != nil {
18-
// log.Fatal(err)
19-
// }
16+
// client, err := resmgmt.New(adminContext)
17+
// if err != nil {
18+
// log.Fatal(err)
19+
// }
2020
//
21-
// attestationParams, err := sgx.CreateAttestationParamsFromEnvironment()
22-
// if err != nil {
23-
// log.Fatal(err)
24-
// }
21+
// attestationParams, err := sgx.CreateAttestationParamsFromEnvironment()
22+
// if err != nil {
23+
// log.Fatal(err)
24+
// }
2525
//
26-
// initReq := resmgmt.LifecycleInitEnclaveRequest{
27-
// ChaincodeID: "my-fpc-chaincode",
28-
// EnclavePeerEndpoint: "mypeer.myorg.example.com", // define the peer where we wanna init our enclave
29-
// AttestationParams: attestationParams,
30-
// }
26+
// initReq := resmgmt.LifecycleInitEnclaveRequest{
27+
// ChaincodeID: "my-fpc-chaincode",
28+
// EnclavePeerEndpoint: "mypeer.myorg.example.com", // define the peer where we wanna init our enclave
29+
// AttestationParams: attestationParams,
30+
// }
3131
//
32-
// initTxId, err := client.LifecycleInitEnclave("mychannel", initReq)
33-
// if err != nil {
34-
// log.Fatal(err)
35-
// }
32+
// initTxId, err := client.LifecycleInitEnclave("mychannel", initReq)
33+
// if err != nil {
34+
// log.Fatal(err)
35+
// }
3636
//
3737
// See also `lifecycle_test.go` and `$FPC_PATH/integration/client_sdk/go/utils/utils.go`
3838
// for a running example.
39-
//
4039
package resmgmt
4140

4241
import (

client_sdk/go/pkg/core/contract/contract.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ type Provider interface {
3636
}
3737

3838
// GetContract is the factory method for creating FPC Contract objects.
39-
// Parameters:
40-
// network is an initialized Fabric network object
41-
// chaincodeID is the ID of the target chaincode
4239
//
43-
// Returns:
44-
// The contractImpl object
40+
// Parameters:
41+
// network is an initialized Fabric network object
42+
// chaincodeID is the ID of the target chaincode
43+
//
44+
// Returns:
45+
// The contractImpl object
4546
func GetContract(p Provider, chaincodeID string) *contractImpl {
4647
ercc := p.GetContract("ercc")
4748
return New(p.GetContract(chaincodeID), ercc, nil, &crypto.EncryptionProviderImpl{

client_sdk/go/pkg/core/lifecycle/client.go

+18-19
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,31 @@ SPDX-License-Identifier: Apache-2.0
1111
//
1212
// Example:
1313
//
14-
// adminContext := sdk.Context(fabsdk.WithUser(orgAdmin), fabsdk.WithOrg(orgName))
14+
// adminContext := sdk.Context(fabsdk.WithUser(orgAdmin), fabsdk.WithOrg(orgName))
1515
//
16-
// client, err := lifecycle.New(adminContext)
17-
// if err != nil {
18-
// log.Fatal(err)
19-
// }
16+
// client, err := lifecycle.New(adminContext)
17+
// if err != nil {
18+
// log.Fatal(err)
19+
// }
2020
//
21-
// attestationParams, err := sgx.CreateAttestationParamsFromEnvironment()
22-
// if err != nil {
23-
// log.Fatal(err)
24-
// }
21+
// attestationParams, err := sgx.CreateAttestationParamsFromEnvironment()
22+
// if err != nil {
23+
// log.Fatal(err)
24+
// }
2525
//
26-
// initReq := lifecycle.LifecycleInitEnclaveRequest{
27-
// ChaincodeID: "my-fpc-chaincode",
28-
// EnclavePeerEndpoint: "mypeer.myorg.example.com", // define the peer where we wanna init our enclave
29-
// AttestationParams: attestationParams,
30-
// }
26+
// initReq := lifecycle.LifecycleInitEnclaveRequest{
27+
// ChaincodeID: "my-fpc-chaincode",
28+
// EnclavePeerEndpoint: "mypeer.myorg.example.com", // define the peer where we wanna init our enclave
29+
// AttestationParams: attestationParams,
30+
// }
3131
//
32-
// initTxId, err := client.LifecycleInitEnclave("mychannel", initReq)
33-
// if err != nil {
34-
// log.Fatal(err)
35-
// }
32+
// initTxId, err := client.LifecycleInitEnclave("mychannel", initReq)
33+
// if err != nil {
34+
// log.Fatal(err)
35+
// }
3636
//
3737
// See also https://github.com/hyperledger/fabric-private-chaincode/blob/main/integration/client_sdk/go/utils.go
3838
// for a running example.
39-
//
4039
package lifecycle
4140

4241
import (

client_sdk/go/pkg/fab/ccpackager/packager.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ Notice: This file is based on fabric-sdk-go/pkg/fab/ccpackager/lifecycle/package
1212
// Package ccpackager provides functionality to package a FPC chaincode.
1313
//
1414
// Example:
15-
// desc := &ccpackager.Descriptor{
16-
// Path: "/my_fpc_chaincode/build/_lib",
17-
// Type: ccpackager.ChaincodeType,
18-
// Label: "my-fpc-chaincode-v1",
19-
// SGXMode: "SIM",
20-
// }
21-
// ccPkg, err := ccpackager.NewCCPackage(desc)
22-
// if err != nil {
23-
// log.Fatal(err)
24-
// }
2515
//
16+
// desc := &ccpackager.Descriptor{
17+
// Path: "/my_fpc_chaincode/build/_lib",
18+
// Type: ccpackager.ChaincodeType,
19+
// Label: "my-fpc-chaincode-v1",
20+
// SGXMode: "SIM",
21+
// }
22+
// ccPkg, err := ccpackager.NewCCPackage(desc)
23+
// if err != nil {
24+
// log.Fatal(err)
25+
// }
2626
package ccpackager
2727

2828
import (
@@ -31,7 +31,7 @@ import (
3131
"compress/gzip"
3232
"encoding/json"
3333
"fmt"
34-
"io/ioutil"
34+
"os"
3535
"path/filepath"
3636
"strings"
3737

@@ -71,7 +71,7 @@ func NewCCPackage(desc *Descriptor) ([]byte, error) {
7171

7272
// ReadMrenclave returns mrenclave for the given FPC chaincode at ccPath
7373
func ReadMrenclave(ccPath string) (string, error) {
74-
mrenclave, err := ioutil.ReadFile(filepath.Join(ccPath, mrenclaveFileName))
74+
mrenclave, err := os.ReadFile(filepath.Join(ccPath, mrenclaveFileName))
7575
if err != nil {
7676
return "", err
7777
}

client_sdk/go/pkg/fab/ccpackager/packager_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ SPDX-License-Identifier: Apache-2.0
77
package ccpackager_test
88

99
import (
10-
"io/ioutil"
1110
"os"
1211
"path/filepath"
1312
"testing"
@@ -173,7 +172,7 @@ var _ = Describe("Go Client SDK Test", func() {
173172
Expect(err).ShouldNot(HaveOccurred())
174173
Expect(payload).ShouldNot(BeNil())
175174

176-
err = ioutil.WriteFile("/tmp/pack.tar.gz", payload, 0644)
175+
err = os.WriteFile("/tmp/pack.tar.gz", payload, 0644)
177176
Expect(err).ShouldNot(HaveOccurred())
178177
})
179178
})

client_sdk/go/pkg/gateway/contract.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ func (cp *contractProvider) GetContract(id string) contract.Contract {
8282
}
8383

8484
// GetContract is the factory method for creating FPC Contract objects.
85-
// Parameters:
86-
// network is an initialized Fabric network object
87-
// chaincodeID is the ID of the target chaincode
8885
//
89-
// Returns:
90-
// The contract object
86+
// Parameters:
87+
// network is an initialized Fabric network object
88+
// chaincodeID is the ID of the target chaincode
89+
//
90+
// Returns:
91+
// The contract object
9192
func GetContract(network Network, chaincodeID string) Contract {
9293
return contract.GetContract(&contractProvider{network: network}, chaincodeID)
9394
}

client_sdk/go/pkg/sgx/attestation.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ package sgx
1010
import (
1111
"encoding/base64"
1212
"encoding/json"
13-
"io/ioutil"
1413
"os"
1514
"path/filepath"
1615
"strings"
@@ -117,7 +116,7 @@ func ReadSigRL(sgxCredentialsPath string) (string, error) {
117116
}
118117

119118
func readFile(path string) (string, error) {
120-
content, err := ioutil.ReadFile(path)
119+
content, err := os.ReadFile(path)
121120
if err != nil {
122121
return "", errors.Wrapf(err, "could not read %s", path)
123122
}

client_sdk/go/pkg/sgx/attestation_test.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ SPDX-License-Identifier: Apache-2.0
77
package sgx_test
88

99
import (
10-
"io/ioutil"
1110
"os"
1211
"path/filepath"
1312
"testing"
@@ -62,7 +61,7 @@ func TestCreateAttestationParamsFromEnvironment(t *testing.T) {
6261

6362
func TestCreateAttestationParamsFromCredentialsPath(t *testing.T) {
6463
// success
65-
testPath, err := ioutil.TempDir("/tmp/", "attestation")
64+
testPath, err := os.MkdirTemp("/tmp/", "attestation")
6665
assert.NoError(t, err)
6766
defer os.RemoveAll(testPath)
6867

@@ -71,15 +70,15 @@ func TestCreateAttestationParamsFromCredentialsPath(t *testing.T) {
7170
assert.Nil(t, attestationParams)
7271
assert.Error(t, err)
7372

74-
err = ioutil.WriteFile(filepath.Join(testPath, "spid_type.txt"), []byte("simulation"), 0644)
73+
err = os.WriteFile(filepath.Join(testPath, "spid_type.txt"), []byte("simulation"), 0644)
7574
assert.NoError(t, err)
7675

7776
// no spid available
7877
attestationParams, err = sgx.CreateAttestationParamsFromCredentialsPath(testPath)
7978
assert.Nil(t, attestationParams)
8079
assert.Error(t, err)
8180

82-
err = ioutil.WriteFile(filepath.Join(testPath, "spid.txt"), []byte("EEEEAAAABBBBAAAEEEEAAAABBBBAAAA"), 0644)
81+
err = os.WriteFile(filepath.Join(testPath, "spid.txt"), []byte("EEEEAAAABBBBAAAEEEEAAAABBBBAAAA"), 0644)
8382
assert.NoError(t, err)
8483

8584
// TODO once ReadSigRL is implemented
@@ -95,7 +94,7 @@ func TestCreateAttestationParamsFromCredentialsPath(t *testing.T) {
9594
}
9695

9796
func TestReadSPIDType(t *testing.T) {
98-
testPath, err := ioutil.TempDir("/tmp/", "attestation")
97+
testPath, err := os.MkdirTemp("/tmp/", "attestation")
9998
assert.NoError(t, err)
10099
defer os.RemoveAll(testPath)
101100

@@ -105,22 +104,22 @@ func TestReadSPIDType(t *testing.T) {
105104
assert.Error(t, err)
106105

107106
// empty spid_type file
108-
err = ioutil.WriteFile(filepath.Join(testPath, "spid_type.txt"), nil, 0644)
107+
err = os.WriteFile(filepath.Join(testPath, "spid_type.txt"), nil, 0644)
109108
assert.NoError(t, err)
110109
spidType, err = sgx.ReadSPIDType(testPath)
111110
assert.Empty(t, spidType)
112111
assert.Error(t, err)
113112

114113
// success
115-
err = ioutil.WriteFile(filepath.Join(testPath, "spid_type.txt"), []byte("simulation"), 0644)
114+
err = os.WriteFile(filepath.Join(testPath, "spid_type.txt"), []byte("simulation"), 0644)
116115
assert.NoError(t, err)
117116
spidType, err = sgx.ReadSPIDType(testPath)
118117
assert.Equal(t, spidType, "simulation")
119118
assert.NoError(t, err)
120119
}
121120

122121
func TestReadSPID(t *testing.T) {
123-
testPath, err := ioutil.TempDir("/tmp/", "attestation")
122+
testPath, err := os.MkdirTemp("/tmp/", "attestation")
124123
assert.NoError(t, err)
125124
defer os.RemoveAll(testPath)
126125

@@ -130,14 +129,14 @@ func TestReadSPID(t *testing.T) {
130129
assert.Error(t, err)
131130

132131
// empty spid file
133-
err = ioutil.WriteFile(filepath.Join(testPath, "spid.txt"), nil, 0644)
132+
err = os.WriteFile(filepath.Join(testPath, "spid.txt"), nil, 0644)
134133
assert.NoError(t, err)
135134
spid, err = sgx.ReadSPID(testPath)
136135
assert.Empty(t, spid)
137136
assert.Error(t, err)
138137

139138
// success
140-
err = ioutil.WriteFile(filepath.Join(testPath, "spid.txt"), []byte("EEEEAAAABBBBAAAEEEEAAAABBBBAAAA"), 0644)
139+
err = os.WriteFile(filepath.Join(testPath, "spid.txt"), []byte("EEEEAAAABBBBAAAEEEEAAAABBBBAAAA"), 0644)
141140
assert.NoError(t, err)
142141
spid, err = sgx.ReadSPID(testPath)
143142
assert.Equal(t, spid, "EEEEAAAABBBBAAAEEEEAAAABBBBAAAA")

common/crypto/attestation-api/test/verify_evidence_app_go/main.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ package main
1010

1111
import (
1212
"fmt"
13-
"io/ioutil"
1413
"os"
1514
"strings"
1615

@@ -58,7 +57,7 @@ func exitIfError(err error) {
5857
}
5958

6059
func readFile(path string) (string, error) {
61-
content, err := ioutil.ReadFile(path)
60+
content, err := os.ReadFile(path)
6261
if err != nil {
6362
return "", errors.Wrapf(err, "could not read %s", path)
6463
}

config.mk

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#--------------------------------------------------
1111
GOFLAGS :=
1212
GO_CMD := go
13-
13+
export GO_BUILD_OPT ?= -buildvcs=false
1414

1515
# Docker related settings
1616
#--------------------------------------------------
@@ -84,6 +84,9 @@ export DOCKERD_FPC_PATH ?= $(FPC_PATH)
8484
# In case you want to use your custom fabric bins, for instance: $(FABRIC_PATH)/build/bin
8585
export FABRIC_BIN_DIR ?= $(FPC_PATH)/fabric/_internal/bin
8686

87+
# another link to the fabric binaries as required by the fabric smart client
88+
export FAB_BINS ?= $(FABRIC_BIN_DIR)
89+
8790
# Additional SGX related settings
8891
#--------------------------------------------------
8992
export SGX_CREDENTIALS_PATH ?= $(FPC_PATH)/config/ias

0 commit comments

Comments
 (0)