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: strange error when building: no Go source files #31004

Closed
yiakwy opened this issue Mar 22, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@yiakwy
Copy link

commented Mar 22, 2019

Files Structure

The root is not inside GOPATH (That is why I use go mod), this is submodule in my cxx project.

.
├── api
│   └── v1
│       └── proxy.go
├── go.mod
├── go.sum
├── pkg
├── pubsub
│   ├── pubsub.pb.go -> /Users/lei.wang1/Github/mold/cpp/network/build/proto_codec/pubsub.pb.go
│   └── pubsub.pb.gw.go -> /Users/lei.wang1/Github/mold/cpp/network/build/proto_codec/pubsub.pb.gw.go

When I tried to build from the root

go build -x api/v1/proxy.go

I got:

➜  go git:(refactor_tmp) ✗ go build -x api/v1/proxy.go  
WORK=/var/folders/0r/8sb7sgx15pg1zqrq7d1kds983135cz/T/go-build718666023
build GO_ROOT/pubsub: cannot load GO_ROOT/pubsub: no Go source files

The pubsub rpc proto module will be referenced by proxy server

package proxy

import (
  "flag"
  "fmt"
  "net/http"
   
  "github.com/golang/glog"
  "golang.org/x/net/context"
  "github.com/grpc-ecosystem/grpc-gateway/runtime"
  "google.golang.org/grpc"
   	
  gw "GO_ROOT/pubsub"
)

Here is my mod info:

module GO_ROOT

go 1.12

require (
	github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
	github.com/grpc-ecosystem/grpc-gateway v1.8.5
	golang.org/x/net v0.0.0-20190322120337-addf6b3196f6
	google.golang.org/grpc v1.19.1
)

Here is my go env

➜  go git:(refactor_tmp) ✗ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/lei.wang1/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/lei.wang1/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/lei.wang1/Github/mold/cpp/network/go/go.mod"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0r/8sb7sgx15pg1zqrq7d1kds983135cz/T/go-build947860107=/tmp/go-build -gno-record-gcc-switches -fno-common"

Expected

I can compile go projects above outside of GoROOT

Actually

It was a painful process before I found go mod to just find out that it does not work at all.

Conclusion

Ridiculous! I treat it as a bug from language or it is a language design problem.

@yiakwy yiakwy changed the title [Bug] Ridiculous build bug: no Go source files [Bug] Ridiculous bug when building: no Go source files Mar 22, 2019

@ALTree ALTree changed the title [Bug] Ridiculous bug when building: no Go source files cmd/go: strange error when building: no Go source files Mar 22, 2019

@ALTree ALTree added this to the Go1.13 milestone Mar 22, 2019

@yiakwy

This comment has been minimized.

Copy link
Author

commented Mar 24, 2019

I resolved the problem by replacing soft links with hard copies. And also I refactored the package modules and importing path. Surprisingly, surprisingly, the program is compiled.

@yiakwy yiakwy closed this Mar 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.