Error “can’t parse patch: parsing time… cannot parse as -0700” began to be faced within golangci-lint on mac. How to sort it out?

If you are facing an error such as the following example:

Can’t run linter goanalysis_metalinter: goimports: can’t extract issues from gofmt diff output “— /Users/camiladeomacedo/go/src/sigs.k8s.io/kubebuilder/pkg/plugins/golang/deploy-image/v1alpha1/api.go.orig\t2022-11-26 17:44:05\n+++ /Users/camiladeomacedo/go/src/sigs.k8s.io/kubebuilder/pkg/plugins/golang/deploy-image/v1alpha1/api.go\t2022-11-26 17:44:05\n@@ -20,9 +20,10 @@\n \t\”errors\”\n \t\”fmt\”\n \t\”os\”\n+\t\”strings\”\n+\n \t\”sigs.k8s.io/kubebuilder/v3/pkg/plugin/util\”\n \tgoPlugin \”sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang\”\n-\t\”strings\”\n \n \t\”github.com/spf13/pflag\”\n \t\”sigs.k8s.io/kubebuilder/v3/pkg/config\”\n”: can’t parse patch: parsing time “2022-11-26 17:44:05” as “2006-01-02 15:04:05 -0700”: cannot parse “” as “-0700” 

ERRO Running error: 1 error occurred:

* can’t run linter goanalysis_metalinter: goimports: can’t extract issues from gofmt diff output “— /Users/camiladeomacedo/go/src/sigs.k8s.io/kubebuilder/pkg/plugins/golang/deploy-image/v1alpha1/api.go.orig\t2022-11-26 17:44:05\n+++ /Users/camiladeomacedo/go/src/sigs.k8s.io/kubebuilder/pkg/plugins/golang/deploy-image/v1alpha1/api.go\t2022-11-26 17:44:05\n@@ -20,9 +20,10 @@\n \t\”errors\”\n \t\”fmt\”\n \t\”os\”\n+\t\”strings\”\n+\n \t\”sigs.k8s.io/kubebuilder/v3/pkg/plugin/util\”\n \tgoPlugin \”sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang\”\n-\t\”strings\”\n \n \t\”github.com/spf13/pflag\”\n \t\”sigs.k8s.io/kubebuilder/v3/pkg/config\”\n”: can’t parse patch: parsing time “2022-11-26 17:44:05” as “2006-01-02 15:04:05 -0700”: cannot parse “” as “-0700”

Then, install the package `brew install diffutils` to sort it out. The root cause is: https://github.com/sourcegraph/go-diff/pull/65 and it will be sort out in future releases.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s