Skip to content

Commit

Permalink
Bump Go to 1.18.2 (#3423)
Browse files Browse the repository at this point in the history
Update staticcheck to a version that works with Go 1.18.
Fix code issues with the new staticcheck.
Fix unit test for new TLS messages and assertion changes in Go 1.18.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
  • Loading branch information
denyeart authored May 17, 2022
1 parent e5ad0ef commit 6588ed2
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ METADATA_VAR += CommitSHA=$(EXTRA_VERSION)
METADATA_VAR += BaseDockerLabel=$(BASE_DOCKER_LABEL)
METADATA_VAR += DockerNamespace=$(DOCKER_NS)

GO_VER = 1.17.5
GO_VER = 1.18.2
GO_TAGS ?=

RELEASE_EXES = orderer $(TOOLS_EXES)
Expand Down
2 changes: 1 addition & 1 deletion ci/azure-pipelines-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pr: none
variables:
GOPATH: $(Agent.BuildDirectory)/go
PATH: $(Agent.BuildDirectory)/go/bin:/usr/local/go/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
GOVER: 1.17.5
GOVER: 1.18.2

jobs:
- job: UnitTests
Expand Down
2 changes: 1 addition & 1 deletion ci/azure-pipelines-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ variables:
- name: GOPATH
value: $(Agent.BuildDirectory)/go
- name: GOVER
value: 1.17.5
value: 1.18.2

stages:
- stage: BuildBinaries
Expand Down
2 changes: 1 addition & 1 deletion ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pr:
variables:
GOPATH: $(Agent.BuildDirectory)/go
PATH: $(Agent.BuildDirectory)/go/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
GOVER: 1.17.5
GOVER: 1.18.2

stages:
- stage: VerifyBuild
Expand Down
2 changes: 1 addition & 1 deletion common/fabhttp/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var _ = Describe("Server", func() {

addApiURL := fmt.Sprintf("https://%s%s", server.Addr(), AdditionalTestApiPath)
_, err = client.Get(addApiURL)
Expect(err.Error()).To(ContainSubstring("tls: protocol version not supported"))
Expect(err.Error()).To(ContainSubstring("tls: no supported versions satisfy MinVersion and MaxVersion"))
})
})

Expand Down
4 changes: 3 additions & 1 deletion common/grpclogging/fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ var _ = Describe("Fields", func() {
field := grpclogging.Error(err)
Expect(field.Key).To(Equal("error"))
Expect(field.Type).To(Equal(zapcore.ErrorType))
Expect(field.Interface).To(Equal(struct{ error }{err}))
// assert that field Interface is of type error
_, ok := field.Interface.(error)
Expect(ok).To(BeTrue())
})

Context("when the error is nil", func() {
Expand Down
2 changes: 1 addition & 1 deletion common/ledger/testutil/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var signer msp.SigningIdentity

func init() {
// setup the MSP manager so that we can sign/verify
var err error = msptesttools.LoadMSPSetupForTesting()
err := msptesttools.LoadMSPSetupForTesting()
if err != nil {
panic(fmt.Errorf("Could not load msp config, err %s", err))
}
Expand Down
2 changes: 1 addition & 1 deletion common/policydsl/policyparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func secondPass(args ...interface{}) (interface{}, error) {
}

/* get the n in the t out of n */
var n int = len(args) - 2
n := len(args) - 2

/* sanity check - t should be positive, permit equal to n+1, but disallow over n+1 */
if t < 0 || t > n+1 {
Expand Down
2 changes: 1 addition & 1 deletion common/viperutil/config_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *ConfigParser) ConfigFileUsed() string {

// Search for the existence of filename for all supported extensions
func (c *ConfigParser) searchInPath(in string) (filename string) {
var supportedExts []string = []string{"yaml", "yml"}
supportedExts := []string{"yaml", "yml"}
for _, ext := range supportedExts {
fullPath := filepath.Join(in, c.configName+"."+ext)
_, err := os.Stat(fullPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ func (dbclient *couchDatabase) listIndex() ([]*indexResult, error) {
designDoc = s[1]

// Add the index definition to the results
addIndexResult := &indexResult{DesignDocument: designDoc, Name: row.Name, Definition: fmt.Sprintf("%s", row.Definition)}
addIndexResult := &indexResult{DesignDocument: designDoc, Name: row.Name, Definition: string(row.Definition)}
results = append(results, addIndexResult)
}

Expand Down
4 changes: 2 additions & 2 deletions docs/source/prereqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ Optional: Install the latest Fabric supported version of [Go](https://golang.org
installed (only required if you will be writing Go chaincode or SDK applications).

```shell
$ brew install go@1.17.5
$ brew install go@1.18.2
$ go version
go1.17.5 darwin/amd64
go1.18.2 darwin/amd64
```

### JQ
Expand Down
2 changes: 1 addition & 1 deletion gotools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ go.fqp.golint := golang.org/x/lint/golint
go.fqp.misspell := github.com/client9/misspell/cmd/misspell
go.fqp.mockery := github.com/vektra/mockery/cmd/mockery
go.fqp.protoc-gen-go := github.com/golang/protobuf/protoc-gen-go
go.fqp.staticcheck := honnef.co/go/tools/cmd/staticcheck
go.fqp.staticcheck := honnef.co/go/tools/cmd/staticcheck@2022.1.1 # 2022.1.1 fixes the staticcheck issue with Go 1.18 "export data is newer version - update tool"
go.fqp.swagger := github.com/go-swagger/go-swagger/cmd/swagger

.PHONY: gotools-install
Expand Down
2 changes: 1 addition & 1 deletion integration/nwo/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *Components) Build(path string) string {
Expect(err).NotTo(HaveOccurred())

if resp.StatusCode != http.StatusOK {
Expect(resp.StatusCode).To(Equal(http.StatusOK), fmt.Sprintf("%s", body))
Expect(resp.StatusCode).To(Equal(http.StatusOK), string(body))
}

return string(body)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/comm/creds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestCreds(t *testing.T) {
MaxVersion: tls.VersionTLS10,
})
wg.Wait()
require.Contains(t, err.Error(), "protocol version not supported")
require.Contains(t, err.Error(), "tls: no supported versions satisfy MinVersion and MaxVersion")
require.Contains(t, recorder.Messages()[1], "TLS handshake failed")
}

Expand Down
2 changes: 1 addition & 1 deletion orderer/common/cluster/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (ci *ChainInspector) Channels() []ChannelGenesisBlock {
}
ci.validateHashPointer(block, prevHash)
// Set the previous hash for the next iteration
prevHash = protoutil.BlockHeaderHash(block.Header) //lint:ignore SA5011 logs and panics above
prevHash = protoutil.BlockHeaderHash(block.Header)

channel, gb, err := ExtractGenesisBlock(ci.Logger, block)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion orderer/common/multichannel/registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (r *Registrar) initSystemChannel(existingChannels []string) {
logger.Infof(
"Starting system channel '%s' with genesis block hash %x and orderer type %s",
channelID,
protoutil.BlockHeaderHash(genesisBlock.Header), //lint:ignore SA5011 logs and panics above
protoutil.BlockHeaderHash(genesisBlock.Header),
chain.SharedConfig().ConsensusType(),
)

Expand Down
2 changes: 1 addition & 1 deletion vagrant/golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# SPDX-License-Identifier: Apache-2.0

GOROOT='/opt/go'
GO_VERSION=1.17.5
GO_VERSION=1.18.2

# ----------------------------------------------------------------
# Install Golang
Expand Down

0 comments on commit 6588ed2

Please sign in to comment.