golangci-lint
golangci-lint copied to clipboard
Can't parse date when running
Welcome
- [X] Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
- [X] Yes, I've searched similar issues on GitHub and didn't find any.
- [X] Yes, I've included all information below (version, config, etc).
- [X] Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)
Description of the problem
When running golangci-lint run -E gofmt
I am shown an error:
WARN [linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649.
ERRO Running error: 1 error occurred:
* can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go.orig\t2022-08-10 12:30:31\n+++ /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go\t2022-08-10 12:30:31\n@@ -4,8 +4,9 @@\n \t\"context\"\n \t\"encoding/json\"\n \t\"fmt\"\n-\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n \t\"net/url\"\n+\n+\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n )\n \n type ReportingClient struct {\n": can't parse patch: parsing time "2022-08-10 12:30:31" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"
Version of golangci-lint
golangci-lint has version 1.46.2 built from a333689 on 2022-05-17T06:05:08Z
Configuration file
---
run:
timeout: 3m
build-tags:
- integration
linters:
enable:
- misspell
- goimports
- revive
- gofmt
- depguard
- godot
Go environment
go version go1.18.2 darwin/arm64
GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/jacek.leszczynski/Library/Caches/go-build"
GOENV="/Users/jacek.leszczynski/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/jacek.leszczynski/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jacek.leszczynski/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.18.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.18.2/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/jc/2hzf075172155k8m2zswff540000gq/T/go-build2249922677=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
INFO [config_reader] Config search paths: [./ /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot /Users/jacek.leszczynski/RiderProjects/reporting-tools/go /Users/jacek.leszczynski/RiderProjects/reporting-tools /Users/jacek.leszczynski/RiderProjects /Users/jacek.leszczynski /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 16 linters: [deadcode depguard errcheck godot gofmt goimports gosimple govet ineffassign misspell revive staticcheck structcheck typecheck unused varcheck]
INFO [loader] Using build tags: [integration]
INFO [loader] Go packages loading at mode 575 (imports|deps|exports_file|files|name|types_sizes|compiled_files) took 379.585375ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 3.7755ms
INFO [linters context/goanalysis] analyzers took 14.276696194s with top 10 stages: buildir: 9.462551828s, inspect: 803.317455ms, fact_deprecated: 507.355007ms, ctrlflow: 430.351534ms, nilness: 429.363872ms, printf: 362.387388ms, fact_purity: 344.798673ms, SA5012: 280.363134ms, the_only_name: 212.144167ms, typedness: 206.551703ms
WARN [runner] Can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go.orig\t2022-08-10 12:33:15\n+++ /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go\t2022-08-10 12:33:15\n@@ -4,8 +4,9 @@\n \t\"context\"\n \t\"encoding/json\"\n \t\"fmt\"\n-\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n \t\"net/url\"\n+\n+\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n )\n \n type ReportingClient struct {\n": can't parse patch: parsing time "2022-08-10 12:33:15" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"
WARN [linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649.
INFO [runner] processing took 2.708µs with stages: max_same_issues: 958ns, nolint: 334ns, max_from_linter: 333ns, skip_dirs: 208ns, severity-rules: 84ns, max_per_file_from_linter: 84ns, filename_unadjuster: 84ns, cgo: 83ns, autogenerated_exclude: 83ns, skip_files: 42ns, path_prefixer: 42ns, path_prettifier: 42ns, path_shortener: 42ns, sort_results: 42ns, diff: 42ns, exclude: 41ns, exclude-rules: 41ns, identifier_marker: 41ns, source_code: 41ns, uniq_by_line: 41ns
INFO [runner] linters took 4.578902583s with stages: goanalysis_metalinter: 4.57884975s, structcheck: 10.291µs
ERRO Running error: 1 error occurred:
* can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go.orig\t2022-08-10 12:33:15\n+++ /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go\t2022-08-10 12:33:15\n@@ -4,8 +4,9 @@\n \t\"context\"\n \t\"encoding/json\"\n \t\"fmt\"\n-\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n \t\"net/url\"\n+\n+\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n )\n \n type ReportingClient struct {\n": can't parse patch: parsing time "2022-08-10 12:33:15" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"
INFO Memory: 51 samples, avg is 823.6MB, max is 1302.8MB
INFO Execution took 4.980535375s
Code example or link to a public repository
Can't share code
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.
Hello,
can you provide your git configuration?
and the information of the diff
installed on your system?
diff --version
Apple diff (based on FreeBSD diff)
git config --list-all
credential.helper=osxkeychain
user.name=Jacek Leszczyński
user.email=<my mail here>
http.sslverify=false
core.autocrlf=input
core.editor=atom --wait~
pull.ff=only
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
submodule.active=.
It feels like your diff
doesn't follow the specification for the timestamp format
https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
@ldez But the date can be shown without a timezone.
I have a similar error:
can't parse patch: parsing time \"2022-08-24 14:35:19\" as \"2006-01-02 15:04:05 -0700\": cannot parse \"\" as \"-0700\""
The specification seems clear: the timezone is not optional.
The timestamp looks like ‘2002-02-21 23:30:39.942229878 -0800’ to indicate the date, time with fractional seconds, and time zone. The fractional seconds are omitted on hosts that do not support fractional timestamps.
I will try to find how to handle diff
command that doesn't follow this spec.
Created an issue in the library where the error occurs: https://github.com/sourcegraph/go-diff/issues/64
Running tests on macOS gives the same error:
ERRO Running error: 1 error occurred:
* can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/borz/Development/com.github/golangci/golangci-lint/internal/robustio/robustio.go.orig\t2022-08-24 17:18:51\n+++ /Users/borz/Development/com.github/golangci/golangci-lint/internal/robustio/robustio.go\t2022-08-24 17:18:51\n@@ -42,9 +42,9 @@\n // in this package attempt to mitigate.\n //\n // Errors considered ephemeral include:\n-// \t- syscall.ERROR_ACCESS_DENIED\n-// \t- syscall.ERROR_FILE_NOT_FOUND\n-// \t- internal/syscall/windows.ERROR_SHARING_VIOLATION\n+// - syscall.ERROR_ACCESS_DENIED\n+// - syscall.ERROR_FILE_NOT_FOUND\n+// - internal/syscall/windows.ERROR_SHARING_VIOLATION\n //\n // This set may be expanded in the future; programs must not rely on the\n // non-ephemerality of any given error.\n": can't parse patch: parsing time "2022-08-24 17:18:51" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"
With your permission, I'll dig further with this issue
The problem comes from the diff
output.
Our CI runs a job on macOS/darwin.
go-diff
has a pattern that follows GNU diff.
For me it's a problem with Apple diff.
Any idea how to install different diff?
brew install diffutils
worked for me.
Support for Apple's diff output was added in https://github.com/sourcegraph/go-diff/commit/7ef5f68ebea1885cdfa8bc710e3d666f95bec1cb, so upgrading the go-diff
dependency will fix this issue.
I will take a look
brew install diffutils
fixes the issue for me
Issue
can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- ........ ..... ..... {\n": can't parse patch: parsing time "2022-11-08 16:49:57" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"
Environment Apple macOs ventura
Thanks @shepherdjerred
The problem with apple diff is now fixed upstream: https://github.com/sourcegraph/go-diff/pull/65
And it looks like it was also updated, so next release should work with apple diff: https://github.com/golangci/golangci-lint/commit/58ebedda6341e2f67d4338eb1d8f75b4a54590d1
brew install diffutils
为我工作。
Thanks
brew install diffutils
is working for me.
thanks
brew install diffutils
worked for me.
thanks
brew install diffutils
worked for me.
Thanks