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

x/text/cmd/gotext: gotext attempts to parse an editor temporary file as json #48983

Closed
mikhirev opened this issue Oct 14, 2021 · 1 comment
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mikhirev
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.16.4 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/dmitry/.local/bin"
GOCACHE="/home/dmitry/.cache/go-build"
GOENV="/home/dmitry/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/dmitry/go/pkg/mod"
GOOS="linux"
GOPATH="/home/dmitry/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.16"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.16/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3274181218=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I use vim to edit translation files. I had a translation file (locales/ru-RU/messages.gotext.json) opened in vim and tried to run gotext update.

What did you expect to see?

gotext generating new catalog file without errors.

What did you see instead?

gotext: import failed: parsing translation file failed: invalid character 'b' looking for beginning of value

Investigation

As I figured out, gotext attempts to parse vim's temporary file locales/ru-RU/.messages.gotext.json.swp as if it were a translation file. I suppose, gotext should ignore such files (i. e. all dotfiles, or only parse files with .json extension).

@gopherbot gopherbot added this to the Unreleased milestone Oct 14, 2021
@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 15, 2021
@seankhliao seankhliao changed the title x/text: gotext attempts to parse an editor temporary file as json x/text/cmd/gotext: gotext attempts to parse an editor temporary file as json Oct 21, 2021
@gopherbot
Copy link

Change https://golang.org/cl/357734 mentions this issue: cmd/gotext: only match files ending with pattern

@dmitshur dmitshur modified the milestones: Unreleased, Go1.18 Nov 9, 2021
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 9, 2021
@dmitshur dmitshur modified the milestones: Go1.18, Unreleased Nov 9, 2021
xhit pushed a commit to xhit/text that referenced this issue Oct 10, 2022
Exclude files with other extensions like .json.swp from editors.

Fixes golang/go#48983

Change-Id: Id74ca7ae208688cf900661d641e5403d453da33c
Reviewed-on: https://go-review.googlesource.com/c/text/+/357734
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Trust: Marcel van Lohuizen <mpvl@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Nov 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants