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

go fmt doesn't work with vendoring mode enabled #35076

Closed
dlsniper opened this issue Oct 22, 2019 · 1 comment
Closed

go fmt doesn't work with vendoring mode enabled #35076

dlsniper opened this issue Oct 22, 2019 · 1 comment

Comments

@dlsniper
Copy link
Contributor

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

$ go version
go version go1.13.3 windows/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
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\flori\AppData\Local\go-build
set GOENV=C:\Users\flori\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS= -mod=vendor
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=github.com/dlsniper
set GONOSUMDB=github.com/dlsniper
set GOOS=windows
set GOPATH=C:\Users\flori\go
set GOPRIVATE=github.com/dlsniper
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\go-sdk\go1.13.3
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\go-sdk\go1.13.3\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\flori\GoLandProjects\awesomeProject10\go.mod
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
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\flori\AppData\Local\Temp\go-build483047210=/tmp/go-build -gno-record-gcc-switches

What did you do?

  • remove/move the $GOPATH/pkg/mod directory
  • create a Go Modules project with the following source code:
package main

import "fmt"
import _ "github.com/gorilla/mux"

func main() {
	fmt.Println("demo")
}
  • run go mod vendor
  • set GOFLAGS=-mod=vendor
  • run go fmt main.go

What did you expect to see?

I expected the Go source code to be formatted.

What did you see instead?

The source code was formatted only after the go fmt command downloaded the github.com/gorilla/mux from the Internet. This is unexpected as I have the source code inside the vendor folder so it shouldn't be downloaded again.

@agnivade
Copy link
Contributor

Duplicate of #27841.

@golang golang locked and limited conversation to collaborators Oct 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants