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

cmd/go: go list error template: main:1: unexpected unclosed action in command #23255

Closed
catafest opened this issue Dec 27, 2017 · 5 comments

Comments

@catafest
Copy link

@catafest catafest commented Dec 27, 2017

Please answer these questions before submitting your issue. Thanks!
this go list error :
go list error: template: main:1: unexpected unclosed action in command

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

go version go1.9.2 windows/amd64

Does this issue reproduce with the latest release?

C:\Go\bin>go list -f '{{ .TestGoFiles }}' archive/tar
template: main:1: unexpected unclosed action in command

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

C:\Go\bin>go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\catafest\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
C:\Go\bin>go list -f '{{ .TestGoFiles }}' archive/tar
template: main:1: unexpected unclosed action in command

What did you expect to see?

[reader_test.go tar_test.go writer_test.go]

What did you see instead?

template: main:1: unexpected unclosed action in command

@mvdan

This comment has been minimized.

Copy link
Member

@mvdan mvdan commented Dec 27, 2017

I'm confused - this works on both 1.9.2 and tip (go version devel +f3f507b2d8 Fri Dec 22 21:13:38 2017 +0000 linux/amd64) on Linux.

$ go list -f '{{ .TestGoFiles }}' archive/tar
[reader_test.go strconv_test.go tar_test.go writer_test.go]
$ go1 list -f '{{ .TestGoFiles }}' archive/tar
[reader_test.go strconv_test.go tar_test.go writer_test.go]

I'm not familiar with the Windows shell, though. Could it be that '{{ .TestGoFiles }}' isn't doing what you are expecting? That is POSIX Shell syntax, so it might not work as-is on Windows.

@catafest

This comment has been minimized.

Copy link
Author

@catafest catafest commented Dec 27, 2017

I don't know if is '{{ .TestGoFiles }}' into go parsing arguments ( I don't deal very much with POSIX), but the output can be also with Windows OS... :
[reader_test.go strconv_test.go tar_test.go writer_test.go].

@mvdan

This comment has been minimized.

Copy link
Member

@mvdan mvdan commented Dec 27, 2017

My point was that perhaps the Windows shell doesn't have single quoted strings. Have you tried go list -f "{{ .TestGoFiles }}" archive/tar?

@catafest

This comment has been minimized.

Copy link
Author

@catafest catafest commented Dec 27, 2017

thank you, works well :
go list -f "{{ .TestGoFiles }}" archive/tar
[reader_test.go strconv_test.go tar_test.go writer_test.go]

@mvdan mvdan closed this Dec 27, 2017
@mikioh mikioh changed the title go list error template: main:1: unexpected unclosed action in command cmd/go: go list error template: main:1: unexpected unclosed action in command Jan 5, 2018
@finalcreator

This comment has been minimized.

Copy link

@finalcreator finalcreator commented Nov 15, 2018

@catafest @mvdan
Actually in windows, ' works well like:
go list -f '{{.Imports}}' github.com/pkg/errors

But I use git bash ( other emulation bash should work too) for better compatibility.
For example, below code only works in bash:
go list -f '{{ join .GoFiles "\n"}}' github.com/pkg/errors

@golang golang locked and limited conversation to collaborators Nov 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants
You can’t perform that action at this time.