-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
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.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.