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: fmt fails if every file in a dir has build constraints #22183

Closed
mjwbyrne opened this issue Oct 9, 2017 · 3 comments
Closed

cmd/go: fmt fails if every file in a dir has build constraints #22183

mjwbyrne opened this issue Oct 9, 2017 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.

Comments

@mjwbyrne
Copy link

mjwbyrne commented Oct 9, 2017

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

go version go1.9.1 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/matt/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build810685112=/tmp/go-build -gno-record-gcc-switches"
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"

What did you do?

  1. Create a directory called "example".
  2. Put several Go source code files in this directory, all with build constraints.
  3. From the parent directory of "example", run "go fmt ./example".

What did you expect to see?

No output, and all files in ./example correctly go fmt'ed.

What did you see instead?

The following error:

can't load package: package ./example: build constraints exclude all Go files in /home/matt/example

Additional information

Placing an extra .go file containing nothing but a package clause in the directory makes go fmt behave properly, i.e. it formats everything in the directory and produces no output.

@ALTree ALTree changed the title go fmt fails if every file in a dir has build constraints cmd/go: fmt fails if every file in a dir has build constraints Oct 9, 2017
@mvdan mvdan added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 9, 2017
@mvdan
Copy link
Member

mvdan commented Oct 9, 2017

Will give this one a go.

@mvdan mvdan self-assigned this Oct 9, 2017
@gopherbot
Copy link

Change https://golang.org/cl/69121 mentions this issue: cmd/go: skip "no buildable go files" in fmt

@gopherbot
Copy link

Change https://golang.org/cl/75930 mentions this issue: cmd/go: skip "exclude all Go files" error in fmt

@golang golang locked and limited conversation to collaborators Nov 5, 2018
@rsc rsc unassigned mvdan Jun 23, 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

3 participants