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

x/tools/gopls: Does GOPACKAGESDRIVER support custom packages ? #69501

Open
ViolaPioggia opened this issue Sep 17, 2024 · 5 comments
Open

x/tools/gopls: Does GOPACKAGESDRIVER support custom packages ? #69501

ViolaPioggia opened this issue Sep 17, 2024 · 5 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ViolaPioggia
Copy link

gopls version

gopls -v version
Build info

golang.org/x/tools/gopls v0.16.1
golang.org/x/tools/gopls@v0.16.1 h1:1hO/dCeUvjEYx3V0rVvCtOkwnpEpqS29paE+Jw4dcAc=
github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
golang.org/x/mod@v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/sync@v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/telemetry@v0.0.0-20240607193123-221703e18637 h1:3Wt8mZlbFwG8llny+t18kh7AXxyWePFycXMuVdHxnyM=
golang.org/x/text@v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/tools@v0.22.1-0.20240628205440-9c895dd76b34 h1:Kd+Z5Pm6uwYx3T2KEkeHMHUMZxDPb/q6b1m+zEcy62c=
golang.org/x/vuln@v1.0.4 h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
honnef.co/go/tools@v0.4.7 h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.22.6

go env

go env
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/violapioggia/Library/Caches/go-build'
GOENV='/Users/violapioggia/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/violapioggia/go/pkg/mod'
GONOPROXY='talkcheap.xiaoeknow.com'
GONOSUMDB='talkcheap.xiaoeknow.com'
GOOS='darwin'
GOPATH='/Users/violapioggia/go'
GOPRIVATE='talkcheap.xiaoeknow.com'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN=''
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/violapioggia/GolandProjects/rgo/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/2y/q5hfz55n7yx__bgtrj0pwgpw0000gn/T/go-build2651212672=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I use GOPACKAGESDRIVER to build a custom package which name's github.com/xxx/xxx

What did you see happen?

when I execute go mod tidy ,it will throw an error:

(base) ViolaPioggiadeMacBook-Air:rgo_test violapioggia$ go mod tidy
go: finding module for package github.com/xxx
go: test imports
github.com/xxx: cannot find module providing package github.com/xxx: module github.com/xxx: git ls-remote -q origin in /Users/violapioggia/go/pkg/mod/cache/vcs/6d9364d47d76a0951f605c504e9f49ac68af057ddde3e30b0f18dcf04c652806: exit status 128:
remote: Repository not found.
fatal: repository 'https://github.com/xxx: not found

What did you expect to see?

I want I can import custom_pacakge github.com/xxx by GOPACKAGESDRIVER like normal package and execute go mod tidy won't throw an error

Editor and settings

{
"go.toolsEnvVars": {
"GOPACKAGESDRIVER": "${env:GOPATH}/bin/mypackagesdriver"
},
}

Logs

No response

@ViolaPioggia ViolaPioggia added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Sep 17, 2024
@gopherbot gopherbot added this to the Unreleased milestone Sep 17, 2024
@li-jin-gou
Copy link

Hello @findleyr , can you help us look into this issue? I'm not sure if this capability is supported now.

@adonovan
Copy link
Member

As far as I can tell, you want the go command to somehow use a custom GOPACKAGESDRIVER, but the go command knows nothing of this concept: it is part of https://pkg.go.dev/golang.org/x/tools/go/packages, which is a library for loading Go project metadata by running build tools like go list, or alternatives such as like bazel, buck, and pants. And I don't see how this relates at all to gopls.

Could you explain the problem in more detail?

@li-jin-gou
Copy link

Sorry @adonovan ,it may have mentioned the wrong issue category.

We use GOPACKAGESDRIVER in the hope of injecting three-way packages, in the form of github.com/hertz_gen/a, but using go mod tidy will go and pull the packages remotely, resulting in a package does not exist error.

I'm currently wondering if GOPACKAGESDRIVER supports emulating three-way packages and go mod tidy doesn't report an error?

We can resubmit an issue to the correct category.

@adonovan
Copy link
Member

We use GOPACKAGESDRIVER in the hope of injecting three-way packages, in the form of github.com/hertz_gen/a, but using go mod tidy will go and pull the packages remotely, resulting in a package does not exist error.
I'm currently wondering if GOPACKAGESDRIVER supports emulating three-way packages and go mod tidy doesn't report an error?

I have not heard the term "three-way package" before. What does it mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants