Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't parse date when running #3087

Closed
4 tasks done
J4cku opened this issue Aug 10, 2022 · 20 comments · Fixed by #3350
Closed
4 tasks done

Can't parse date when running #3087

J4cku opened this issue Aug 10, 2022 · 20 comments · Fixed by #3350
Labels
bug Something isn't working

Comments

@J4cku
Copy link

J4cku commented Aug 10, 2022

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • 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

@J4cku J4cku added the bug Something isn't working label Aug 10, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 10, 2022

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez ldez self-assigned this Aug 10, 2022
@ldez
Copy link
Member

ldez commented Aug 10, 2022

Hello,

can you provide your git configuration?
and the information of the diff installed on your system?

@ldez ldez added the feedback required Requires additional feedback label Aug 10, 2022
@J4cku
Copy link
Author

J4cku commented Aug 10, 2022

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=.

@ldez
Copy link
Member

ldez commented Aug 10, 2022

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

@BorzdeG
Copy link

BorzdeG commented Aug 24, 2022

@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\""

@ldez
Copy link
Member

ldez commented Aug 24, 2022

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.

@BorzdeG
Copy link

BorzdeG commented Aug 24, 2022

Created an issue in the library where the error occurs: sourcegraph/go-diff#64

@BorzdeG
Copy link

BorzdeG commented Aug 24, 2022

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

@ldez
Copy link
Member

ldez commented Aug 24, 2022

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.

@J4cku
Copy link
Author

J4cku commented Aug 24, 2022

Any idea how to install different diff?

@shepherdjerred
Copy link

brew install diffutils worked for me.

@fjl
Copy link

fjl commented Nov 7, 2022

Support for Apple's diff output was added in sourcegraph/go-diff@7ef5f68, so upgrading the go-diff dependency will fix this issue.

@ldez
Copy link
Member

ldez commented Nov 7, 2022

I will take a look

@asalan316
Copy link

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

@freeformz
Copy link

The problem with apple diff is now fixed upstream: sourcegraph/go-diff#65

@freeformz
Copy link

And it looks like it was also updated, so next release should work with apple diff: 58ebedd

@itgcl
Copy link

itgcl commented Nov 16, 2022

brew install diffutils为我工作。

Thanks

@priyankshah217
Copy link

brew install diffutils is working for me.

thanks

@thomasshen-crypto
Copy link

brew install diffutils worked for me.

thanks

@rahulanand90
Copy link

brew install diffutils worked for me.

Thanks

@golangci golangci locked as resolved and limited conversation to collaborators Jan 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.