odo icon indicating copy to clipboard operation
odo copied to clipboard

Upgrade odo to use go 1.18

Open valaparthvi opened this issue 3 years ago • 6 comments

/kind user-story

NOTE: this issue has been modified to update odo to use go 1.18. Refer https://github.com/redhat-developer/odo/issues/6090#issuecomment-1254819875 for additional context.

User Story

As an odo-dev I want to odo to be work with Go 1.19 so that if I want to use the latest version, it does not break odo. There are a few discrepancies between the currently supported version and 1.19.

odo currently uses go 1.17, support for which ended with go1.19

Acceptance Criteria

  • [ ] It should not break checks from the openshift-presubmit-unittest.
  • [ ] release scripts end brew environment needs to be updated and verified that Go 1.19 can be used for building release artifacts
  • [ ] check what's supported by the Build team

Links

  • Related Epic (mandatory):

/kind user-story

valaparthvi avatar Sep 05 '22 08:09 valaparthvi

As an odo-dev I want to odo to be work with Go 1.19 so that if I want to use the latest version, it does not break odo. There are a few discrepancies between the currently supported version and 1.19.

Is there a feature in go 1.19 that we need/want to use? If yes, we should consider this issue. If not, I don't think we should spend time on this just because go 1.19 is the latest version of go.

I am open to counter view(s) and change my opinion based on a valid argument.

dharmit avatar Sep 05 '22 10:09 dharmit

I am open to counter view(s) and change my opinion based on a valid argument.

support for Go 1.17, which odo currently uses, ended with the 1.19 release.

Each major Go release is supported until there are two newer major releases. source: https://go.dev/doc/devel/release#policy

kadel avatar Sep 05 '22 14:09 kadel

I am open to counter view(s) and change my opinion based on a valid argument.

support for Go 1.17, which odo currently uses, ended with the 1.19 release.

Each major Go release is supported until there are two newer major releases. source: https://go.dev/doc/devel/release#policy

+1 I forgot to mention that in the issue description.

valaparthvi avatar Sep 05 '22 14:09 valaparthvi

if there are issues with upgrading to 1.19 (because it is still too new) we can upgrade to 1.18. But using 1.17 is not ok, as it is no longer getting security fixes

kadel avatar Sep 09 '22 10:09 kadel

We discussed this in the planning call to upgrade to 1.18 because the ART team builds against 1.18 at the moment. Modifying the issue title accordingly.

dharmit avatar Sep 22 '22 10:09 dharmit

Steps followed by me:

  1. Update the local go distribution. I had go 1.17.6 which I updated to go 1.18.6 (latest in go 1.18 release) by downloading from the official website.
  2. Modify go.mod to use go 1.18 a. Run go mod vendor and go mod tidy b. Run make install. Everything works fine.
  3. Run make validate which failed with error which made me update the staticcheck as mentioned in further steps. Unfortunately, I don't have the output of make validate failure that prompted me to do this.
  4. I checked the version of staticcheck on my system using staticcheck -debug.version:
    $ staticcheck -debug.version
    staticcheck 2022.1.2 (v0.3.2)
    
    Compiled with Go version: go1.17.6
    Main module:
        honnef.co/go/[email protected] (sum: h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=)
    Dependencies:
        github.com/BurntSushi/[email protected] (sum: h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=)
        golang.org/x/exp/[email protected] (sum: h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=)
        golang.org/x/[email protected] (sum: h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=)
        golang.org/x/[email protected] (sum: h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=)
        golang.org/x/[email protected] (sum: h1:OKYpQQVE3DKSc3r3zHVzq46vq5YH7x8xpR3/k9ixmUg=)
    
  5. The line Compiled with Go version: go1.17.6 didn't seem OK to me because I had updated to go 1.18 on my local system. So, I did:
    $ go install honnef.co/go/tools/cmd/[email protected]
    
    $ staticcheck -debug.version
    staticcheck 2022.1.2 (v0.3.2)
    
    Compiled with Go version: go1.18.6
    Main module:
            honnef.co/go/[email protected] (sum: h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=)
    Dependencies:
            github.com/BurntSushi/[email protected] (sum: h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=)
            golang.org/x/exp/[email protected] (sum: h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=)
            golang.org/x/[email protected] (sum: h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=)
            golang.org/x/[email protected] (sum: h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=)
            golang.org/x/[email protected] (sum: h1:OKYpQQVE3DKSc3r3zHVzq46vq5YH7x8xpR3/k9ixmUg=)
    
  6. make validate now fails with:
    golangci-lint run ./... --timeout 15m
    WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package goarch: could not load export data: cannot import "internal/goarch" (unknown iexport format version 2), export data is newer version - update tool 
    WARN [runner] Can't run linter unused: buildir: failed to load package goarch: could not load export data: cannot import "internal/goarch" (unknown iexport format version 2), export data is newer version - update tool 
    ERRO Running error: buildir: failed to load package goarch: could not load export data: cannot import "internal/goarch" (unknown iexport format version 2), export data is newer version - update tool 
    make: *** [Makefile:96: golint] Error 3
    
  7. I decided to upgrade golangci-lint which is locked to version 1.37.0 in odo's Makefile:
    $ go install github.com/golangci/golangci-lint/cmd/[email protected]
    
  8. Now make validate fails with:
    golangci-lint run ./... --timeout 15m
    pkg/storage/storage.go:73:2: ineffectual assignment to storageClusterList (ineffassign)
    	storageClusterList := StorageList{}
    	^
    pkg/odo/cli/create/namespace/namespace.go:104:58: SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
    	successMessage := fmt.Sprintf(`%s %q is ready for use`, strings.Title(nco.commandName), nco.namespaceName)
    															^
    pkg/odo/cli/delete/namespace/namespace.go:103:4: SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
    			strings.Title(do.commandName), do.namespaceName)
    			^
    pkg/api/component.go:32:24: SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
    			strs = append(strs, strings.Title(string(s)))
    								^
    pkg/odo/util/cmdutils.go:29:40: SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
    				printstring := fmt.Sprintf("%s%s", strings.Title(context), "\nError: %v")
    												^
    tests/integration/cmd_namespace_test.go:72:53: SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
    						ContainSubstring(fmt.Sprintf("%s %q deleted", strings.Title(commandName), namespace)))
    																	^
    pkg/util/util_test.go:1418:39: SA9002: file mode '644' evaluates to 01204; did you mean '0644'? (staticcheck)
    				if e := os.Mkdir(dir, os.FileMode(644)); e != nil {
    
  9. Above issues were fixed and opened the PR.

dharmit avatar Sep 22 '22 15:09 dharmit