Skip to content

cmd/tool/compile: go build cannot generate executable file #55853

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

Closed
hitzhangjie opened this issue Sep 25, 2022 · 5 comments
Closed

cmd/tool/compile: go build cannot generate executable file #55853

hitzhangjie opened this issue Sep 25, 2022 · 5 comments

Comments

@hitzhangjie
Copy link
Contributor

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

$ go version

go version go1.19.1 darwin/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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/zhangjie/Library/Caches/go-build"
GOENV="/Users/zhangjie/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/zhangjie/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/zhangjie/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/zhangjie/Downloads/image/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 x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0j/mvtnlhyj5j9cyqqq1b27bgg40000gn/T/go-build4139814822=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I create following files under folder image:

file1: go.mod

module image

go 1.19

file2:

package main

import "fmt"

func main() {
	fmt.Println("hello world")
}

Then I run go build, then no any error reported, and echo $? outputs 0. That said go build success, but no any executable generated.

What did you expect to see?

I think it should generate the executable.

What did you see instead?

No executable generated. Go compiler doesn't differentiate go inner image package and user-defined image module? If I rename module image to xxx/image, it works as expected.

@ryicoh
Copy link

ryicoh commented Sep 25, 2022

That's true, but i think it should print errors instead of generate the executable.

@hitzhangjie
Copy link
Contributor Author

Good idea.

Should the standard library or any package in go/src be considered a module?

@ryicoh
Copy link

ryicoh commented Sep 25, 2022

Yes, and should throw the error that package name is duplicated.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/434095 mentions this issue: cmd/go: show error when mod name conflict with std lib path

@bcmills
Copy link
Contributor

bcmills commented Sep 26, 2022

Duplicate of #35270

@bcmills bcmills marked this as a duplicate of #35270 Sep 26, 2022
@bcmills bcmills closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2022
@golang golang locked and limited conversation to collaborators Sep 26, 2023
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

4 participants